Skip to content

[Woo POS][Refunds] Allow adding refund reason#15173

Merged
samiuelson merged 18 commits intotrunkfrom
woomob-1775-woo-posrefunds-allow-adding-a-refund-reason-while-creating-a
Jan 20, 2026
Merged

[Woo POS][Refunds] Allow adding refund reason#15173
samiuelson merged 18 commits intotrunkfrom
woomob-1775-woo-posrefunds-allow-adding-a-refund-reason-while-creating-a

Conversation

@samiuelson
Copy link
Contributor

@samiuelson samiuelson commented Jan 8, 2026

WOOMOB-1775
Figma: DK955L5K0bTfkjrHTBLmqo-fi-315_28376

Description

This PR adds the possibility to add a refund reason when creating a refund in POS. Additionally, it adds support for handling system back press.

💡 The UI was made consistent with WooPosEmailReceiptScreen. That's reason why some details from Figma were omitted, e.g. redundant X button.

💡 Do not merge until parent branch is trunk.

Test Steps

  1. Go to POS order
  2. Select refundable order and start refund flow
  3. While in the "Review refund" step, tap "Edit reason" button
  4. Enter reason in the input form
  5. Proceed with refund
  6. Verify the refund reason was saved and can be seen in the wp-admin

Images/gif

image image image
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@samiuelson samiuelson changed the title Allow adding refund reason [Woo POS][Refunds] Allow adding refund reason Jan 8, 2026
@dangermattic
Copy link
Collaborator

dangermattic commented Jan 8, 2026

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 8, 2026

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commita074d7e
Direct Downloadwoocommerce-wear-prototype-build-pr15173-a074d7e.apk

…nds-allow-adding-a-refund-reason-while-creating-a
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 8, 2026

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commita074d7e
Direct Downloadwoocommerce-prototype-build-pr15173-a074d7e.apk

* Extract reason input field composable to external file
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds functionality to the WooCommerce POS refund flow that allows users to add an optional refund reason. Users can click "Edit reason" (or "Add") on the review refund screen to enter a reason, which is then passed to the refund store when confirming the refund.

Key Changes:

  • Added refund reason state management with edit/save/cancel operations
  • Created a new full-screen reason entry interface with keyboard focus
  • Refactored event handling in the ViewModel for better organization

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
WooPosRefundUIEvent.kt Added four new UI events for handling refund reason editing (EditReasonClicked, SaveReasonClicked, CancelReasonEditClicked, OnRefundReasonChanged)
WooPosRefundState.kt Added refundReason and isEditingReason properties to Content state with appropriate defaults
WooPosRefundViewModel.kt Refactored event handling into separate methods and integrated refund reason into the refund creation flow
WooPosRefundReasonScreen.kt New composable screen for entering/editing refund reason with auto-focus and keyboard support
WooPosIssueRefundDialog.kt Integrated reason screen as an overlay, added Edit reason button with accessibility support, and removed placeholder reason text
WooPosRefundViewModelTest.kt Added comprehensive tests for reason editing state transitions and refund creation with/without reason
strings.xml Added four new string resources for refund reason UI elements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@samiuelson samiuelson added this to the 23.9 milestone Jan 8, 2026
@samiuelson samiuelson added the type: task An internally driven task. label Jan 8, 2026
@samiuelson samiuelson requested a review from Copilot January 8, 2026 18:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 13.29114% with 137 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.66%. Comparing base (b64c031) to head (a074d7e).
⚠️ Report is 23 commits behind head on trunk.

Files with missing lines Patch % Lines
...ndroid/ui/woopos/orders/WooPosIssueRefundDialog.kt 0.00% 84 Missing ⚠️
...d/ui/woopos/orders/WooPosRefundReasonNavigation.kt 0.00% 38 Missing ⚠️
...android/ui/woopos/orders/WooPosOrdersNavigation.kt 0.00% 7 Missing ⚠️
.../android/ui/woopos/orders/WooPosRefundViewModel.kt 82.60% 1 Missing and 3 partials ⚠️
...os/root/navigation/WooPosNavigationEventHandler.kt 0.00% 2 Missing ⚠️
...d/ui/woopos/root/navigation/WooPosMainFlowGraph.kt 0.00% 1 Missing ⚠️
...ui/woopos/root/navigation/WooPosNavigationEvent.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #15173      +/-   ##
============================================
- Coverage     38.67%   38.66%   -0.02%     
- Complexity    10534    10537       +3     
============================================
  Files          2193     2194       +1     
  Lines        124768   124847      +79     
  Branches      17251    17267      +16     
============================================
+ Hits          48257    48267      +10     
- Misses        71630    71700      +70     
+ Partials       4881     4880       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wpmobilebot wpmobilebot modified the milestones: 23.9, 24.0 Jan 9, 2026
@wpmobilebot
Copy link
Collaborator

Version 23.9 has now entered code-freeze, so the milestone of this PR has been updated to 24.0.

@samiuelson samiuelson added the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Jan 9, 2026
@samiuelson samiuelson requested a review from kidinov January 9, 2026 13:44
@samiuelson samiuelson marked this pull request as ready for review January 9, 2026 13:44
handleDismiss()
}

Box(modifier = Modifier.fillMaxSize()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this box needed here?

}
val stateSnapshot = state
if (stateSnapshot is WooPosRefundState.Content && stateSnapshot.isEditingReason) {
WooPosRefundReasonScreen(
Copy link
Contributor

@kidinov kidinov Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe to follow the same pattern as with email and cash when it's another screen with navigation? Orders is already by far the largest feature, and, in my opinion, adding to it even more not reasonable

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored in 7fcee54

val formattedTotal: String,
val paymentMethod: String,
val refundReason: String = "",
val isEditingReason: Boolean = false,
Copy link
Contributor

@kidinov kidinov Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a boolean variable like that doesn't make the code look better - one more reason to have the reason as a separate screen that returns a result back.

Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of questions, and I noticed a few things, which could be due to WIP, but just letting you know:

  • The loading dialog fills all the screen and is even partially hidden below the bottom system bar
  • There is no animation between sizes of the dialogs - check how it's done on the barcode scanner setup flow
  • There is no animation of the opening of the full "reason" screen, so it doesn't match with cash and email screens, which visually are the same. Overall, we animate from left to right when we go somewhere.
  • Even if it will be decided to keep this link like based approach "edit/add reason" button, we at least can make the whole refund reason row clickable to make it easier to use
01-09--15-52.mp4

Base automatically changed from woomob-1855-create-refund to trunk January 14, 2026 13:33
@samiuelson samiuelson removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Jan 20, 2026
@kidinov kidinov self-requested a review January 20, 2026 14:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosRefundViewModelTest.kt:482

  • This test verifies that the step changes correctly when navigating back, but it doesn't verify that the refundReason is preserved during this navigation. Consider adding an assertion to verify that the refundReason remains unchanged after navigating back to SelectItems, especially since users may have entered a reason before navigating back. This would ensure the refund reason isn't accidentally lost during navigation between steps.
    fun `given content state at ReviewRefund step, when BackToSelectItemsClicked event, then step changes to SelectItems`() =
        runTest {
            // GIVEN
            val refundableItems = listOf(testRefundableItem)
            whenever(ordersDataSource.refreshOrderById(testOrderId)).thenReturn(Result.success(testOrder))
            whenever(retrieveOrderRefunds.invoke(testOrder)).thenReturn(Result.success(emptyList()))
            whenever(getRefundableItems.invoke(any(), any())).thenReturn(refundableItems)

            viewModel = createViewModel()
            advanceUntilIdle()

            viewModel.onUIEvent(WooPosRefundUIEvent.ContinueToReviewClicked)
            val reviewState = viewModel.state.value as WooPosRefundState.Content
            assertThat(reviewState.step).isEqualTo(WooPosRefundState.Content.RefundStep.ReviewRefund)

            // WHEN
            viewModel.onUIEvent(WooPosRefundUIEvent.BackToSelectItemsClicked)

            // THEN
            val updatedState = viewModel.state.value as WooPosRefundState.Content
            assertThat(updatedState.step).isEqualTo(WooPosRefundState.Content.RefundStep.SelectItems)
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@samiuelson samiuelson enabled auto-merge January 20, 2026 19:06
@samiuelson samiuelson merged commit d7cf316 into trunk Jan 20, 2026
16 of 17 checks passed
@samiuelson samiuelson deleted the woomob-1775-woo-posrefunds-allow-adding-a-refund-reason-while-creating-a branch January 20, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants