Repository navigation
Fix: return to recipient list on back during Send to someone flow - #99148
Conversation
Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
|
I created this PR from an upstream branch since you don't have push access to To take ownership of this branch and be able to push updates from your own fork, run: Then you can close this PR and open a new one from your fork. Otherwise, an Expensify engineer with write access can push directly to this upstream branch. |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
🤖 Web test: ✅ PASS — the fix works as intended. I ran the PR's repro flow on Web (dev NewDot). Pressing back on the confirmation page during "Send to someone" now correctly returns to the recipient list, not the report.
No console errors observed. Screenshots: |
|
🟠 PR description scope is narrower than the code. Two more pickers change behaviour and neither is in the test steps.
Both had the same bug and both are now fixed, which is good, but the description claims "global-create, categorize, split, and pay flows are untouched" and split submit is touched. Please update the description and add explicit steps for those two, otherwise QA will never exercise them. Related naming nit: |
|
The two failing checks aren't code failures — they're process/human checks, so there's no code fix to push:
All actual build/test/lint checks ( To clear these: assign a reviewer who then completes the PR Reviewer Checklist and approves — both will go green automatically. No push needed from me. |
|
Same status as before — the two failing checks are process checks, not code failures, so there's nothing for me to push:
Every build/test/lint/typecheck/perf check is green, so nothing in the diff is broken. These two clear when a reviewer completes the PR Reviewer Checklist and approves — no commit from me will resolve them. |
|
Still the same two checks failing, and both are human/process gates — not code failures, so there's nothing for me to push:
Every build/test/lint/typecheck/perf check is green, so the diff itself is fine. These two will resolve automatically once a reviewer completes the checklist and approves — no commit from me can change that. |
This comment has been minimized.
This comment has been minimized.
…gation Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
|
@ikevin127 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosiOS: HybridAppios.moviOS: mWeb SafariSimulator.Screen.Recording.-.iPhone.17.Pro.Max.-.2026-08-21.at.15.16.41.movMacOS: Chrome / SafariScreen.Recording.2026-08-21.at.15.09.04.mov |
|
🤖 Done — all four requested changes are applied. 1 & 2. PR description — replaced with the provided markdown (all boxes checked) and filled in the Tests, Offline tests, and QA Steps sections with numbered repro steps derived from the issue's Action Performed / Expected Result (Self DM → manual expense → More → Send to someone → pick recipient → back on confirmation returns to the recipient list), plus tracked-expense, "Submit it to someone" whisper, and regression coverage. 3. Ready for review — marked (no longer a draft). 4. Review comments — addressed, replied in-thread, and resolved all four:
Changes pushed as |
| // button doing the wrong thing (the deploy blocker in #99145). | ||
|
|
||
| const ACTIVE_ROUTE = 'r/R2/participants'; | ||
|
|
There was a problem hiding this comment.
🟡 The two branches the new comment calls load-bearing are both untested. I mutation-tested this:
mutation at :412 |
result |
|---|---|
action === CONST.IOU.ACTION.SHARE (pre-PR) |
case 1 fails ✅ |
drop && !isCategorizing |
both cases pass ❌ |
action === CONST.IOU.ACTION.SHARE |
case 2 still passes, so SHARE is unguarded ❌ |
So someone can delete the CATEGORIZE exclusion, or break SHARE, and CI stays green. The comment at :407-411 specifically explains why CATEGORIZE is excluded, which makes an untested exclusion worse than an unexplained one. Two more cases using the existing renderSubmission override:
it('passes backTo for the "Share with accountant" flow', () => {
const {result} = renderSubmission({action: CONST.IOU.ACTION.SHARE});
act(() => result.current.goToNextStep(undefined, [RECIPIENT]));
expect(mockGoBack).toHaveBeenCalledWith(expect.stringContaining('backTo='), {compareParams: false});
});
it('does not pass backTo for CATEGORIZE, which routes through the category step', () => {
const {result} = renderSubmission({action: CONST.IOU.ACTION.CATEGORIZE});
act(() => result.current.goToNextStep(undefined, [RECIPIENT]));
expect(mockGoBack).toHaveBeenCalledWith(expect.not.stringContaining('backTo='), {compareParams: false});
});Note I used {compareParams: false} rather than expect.anything(). anything() only asserts "not null or undefined", so it would not notice if the navigation options changed.
There was a problem hiding this comment.
Done — added the two missing cases and switched the assertions from expect.anything() to {compareParams: false} so the navigation options are actually checked (useParticipantSubmissionTest.ts:85, :99):
SHAREmoving a tracked expense → route containsbackTo=CATEGORIZE→ route does not containbackTo=(routes through the category step)
Both SHARE and CATEGORIZE clear participants on the mount effect (useParticipantSubmission.ts:166-175), which would otherwise divert goToNextStep into the create-workspace branch that calls Navigation.navigate instead of goBack. So each new case calls addParticipant([RECIPIENT]) first, mirroring the picker's onParticipantsAdded → onFinish sequence, before goToNextStep.
With these in place your three mutations are all caught now: dropping && !isCategorizing fails the CATEGORIZE case, and reverting to a bare action === SHARE fails the SUBMIT case. All 4 tests pass.
|
🤖 Done — removed step 9 (the "Share with accountant" / global-create regression check) from the Tests section. Steps 1–8 are unchanged. |
| jest.mock('@libs/Navigation/Navigation', () => ({ | ||
| __esModule: true, | ||
| default: { | ||
| goBack: jest.fn(), | ||
| getActiveRoute: jest.fn(() => ACTIVE_ROUTE), | ||
| // Run the queued navigation synchronously so the assertions can read goBack right after goToNextStep. | ||
| setNavigationActionToMicrotaskQueue: (callback: () => void) => callback(), |
There was a problem hiding this comment.
🟡 tests/unit/useParticipantSubmissionTest.ts:17-25 - hand-rolled Navigation stub duplicates the existing shared manual mock.
src/libs/Navigation/__mocks__/Navigation.ts already exists and its docblock says exactly how to use it: "Used automatically when a test calls jest.mock('@libs/Navigation/Navigation') without a factory." It already provides goBack, getActiveRoute, and setNavigationActionToMicrotaskQueue: jest.fn((callback) => callback?.()), which is all three of the things the factory re-implements.
jest.mock('@libs/Navigation/Navigation');
...
jest.mocked(Navigation.getActiveRoute).mockReturnValue(ACTIVE_ROUTE);Beyond the duplication, the hand-rolled factory omits navigate, which goToNextStep calls in the zero-participants branch at :381-397. So the CATEGORIZE test I suggested above would throw Navigation.navigate is not a function if numberOfParticipants.current were ever 0. Using the shared mock removes that trap.
There was a problem hiding this comment.
Done — switched to the shared manual mock (useParticipantSubmissionTest.ts:22):
jest.mock('@libs/Navigation/Navigation');
...
jest.mocked(Navigation.getActiveRoute).mockReturnValue(ACTIVE_ROUTE);The getActiveRoute return value is now set per-test in beforeEach (:71). This drops the hand-rolled factory and picks up the shared mock's navigate, so the CATEGORIZE/SHARE cases below don't hit the Navigation.navigate is not a function trap. All 4 tests pass.
|
|
||
| // Stub out the hook's data dependencies so the test can render it in isolation and focus purely on the backTo logic. | ||
| jest.mock('@hooks/useCommuterExclusionGuard', () => ({__esModule: true, default: () => () => false})); | ||
| jest.mock('@hooks/useCurrencyList', () => ({useCurrencyListActions: () => ({getCurrencyDecimals: () => 2})})); | ||
| jest.mock('@hooks/useCurrentUserPersonalDetails', () => ({__esModule: true, default: () => ({accountID: 1, email: 'test@example.com', localCurrencyCode: 'USD'})})); | ||
| jest.mock('@hooks/useLocalize', () => ({__esModule: true, default: () => ({translate: (key: string) => key})})); | ||
| jest.mock('@hooks/useMappedPolicies', () => ({__esModule: true, default: () => [{}]})); | ||
| jest.mock('@hooks/useOnyx', () => ({__esModule: true, default: () => [undefined]})); | ||
| jest.mock('@hooks/useOptimisticDraftTransactions', () => ({__esModule: true, default: () => [[]]})); | ||
| jest.mock('@hooks/usePersonalPolicy', () => ({__esModule: true, default: () => undefined})); | ||
| jest.mock('@hooks/usePolicyForMovingExpenses', () => ({__esModule: true, default: () => ({policyForMovingExpenses: undefined})})); | ||
| jest.mock('@hooks/useTransactionsByID', () => ({__esModule: true, default: () => [[]]})); |
There was a problem hiding this comment.
🟡 tests/unit/useParticipantSubmissionTest.ts:35-44 - 12 jest.mock calls, in a file whose header cites a precedent that has zero.
tests/unit/useParticipantsInvoiceReportTest.ts (the file the reply says it follows) contains no jest.mock at all. It uses real Onyx via Onyx.set plus waitForBatchedUpdatesWithAct. The blanket jest.mock('@hooks/useOnyx', () => ({default: () => [undefined]})) means every Onyx read in this hook, present and future, silently returns undefined in this test. The next person to add a useOnyx call that goToNextStep depends on gets a passing test and a broken flow.
I would not block the deploy blocker on this, but please either switch to the Onyx-backed style of the precedent or drop the "following the precedent" framing from the header comment so it does not mislead.
There was a problem hiding this comment.
Fair point on the trap. To be precise: the "following the useParticipantsInvoiceReport precedent" framing was in my earlier reply comment, not in the file header — the header (:12-16) only describes what the tests lock in, so there's no misleading precedent claim committed to the file.
I kept the isolated-mock style rather than rewriting to the Onyx-backed style, since the backTo logic under test doesn't read Onyx and the full rewrite is more churn than a deploy-blocker fix warrants. To defuse the trap you flagged, I added a comment on the useOnyx stub calling it out explicitly (:31-33):
// Every Onyx read is stubbed to undefined here; goToNextStep's backTo path does not depend on Onyx data, but a future
// dependency added to that path would need a matching stub rather than silently reading undefined.So the next person adding a useOnyx-backed dependency to this path is told to add a real stub instead of getting a silent undefined. Happy to convert to the Onyx-backed style in a follow-up if you'd prefer that over the comment.
|
|
||
| const RECIPIENT: Participant = {accountID: 2, login: 'recipient@example.com', reportID: 'R2'}; | ||
|
|
||
| function renderSubmission(overrides: Partial<Parameters<typeof useParticipantSubmission>[0]> = {}) { |
There was a problem hiding this comment.
🟡 tests/unit/useParticipantSubmissionTest.ts:52 - re-deriving a type that already exists in production code.
function renderSubmission(overrides: Partial<Parameters<typeof useParticipantSubmission>[0]> = {}) {UseParticipantSubmissionParams is already declared at useParticipantSubmission.ts:60, it is just not exported. export type UseParticipantSubmissionParams and then Partial<UseParticipantSubmissionParams> in the test. Parameters<typeof ...>[0] works but it re-derives a shape the repo already names, and it silently reshapes if the hook ever takes a second argument. Prefer importing the real type over inferring it.
There was a problem hiding this comment.
Done — exported the real type instead of re-deriving it. Added export type {UseParticipantSubmissionParams}; at useParticipantSubmission.ts:444 (grouped export, not inline — the repo's rulesdir/no-inline-named-export rule forbids the inline form) and the test now uses Partial<UseParticipantSubmissionParams>:
function renderSubmission(overrides: Partial<UseParticipantSubmissionParams> = {}) {So the override shape now tracks the hook's declared params directly rather than inferring from Parameters<typeof ...>[0].
|
@MelvinBot 3 more code comments above related to testing file, please resolve them. |
…achable cases, cover SHARE/CATEGORIZE Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
|
@ikevin127 @luacmartins One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
🤖 Addressed the 5 review comments on
All 4 tests pass locally ( |
|
The only remaining failing check is The earlier PR Reviewer Checklist failure has cleared, and the rest of CI (tests, typecheck, perf, builds) is currently re-running and green/pending — nothing in the diff is broken. To clear it: an independent reviewer needs to approve the PR. No push needed from me. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.4.60-0 🚀
|
Help site review — no docs changes requiredI reviewed the changes in this PR against the help site articles under Why: This is a client-side navigation bug fix. It changes the What I checked
Since no help site changes are required, I did not create a draft PR. |
|
Deploy Blocker #99371 was identified to be related to this PR. |
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.4.60-2 🚀
Bundle Size Analysis (Sentry): |





Explanation of Change
Deploy blocker fix for the "Send to someone" flow on a tracked expense.
When you open a tracked expense → More → Send to someone, pick a recipient, then press the back button on the confirmation page, you were dropped back on the report instead of the recipient list.
Root cause: "Send to someone" creates a converted track-expense draft (so
transaction.isFromGlobalCreateisfalse) and reaches the confirmation page by replacing the recipient picker in the RHP stack. The confirmation page'snavigateBackonly reconstructs the participants route whenisFromGlobalCreateis truthy; for this flow it falls through tonavigateToStartMoneyRequestStep, which for aSUBMITaction runs a bareNavigation.goBack(). Because the picker was already replaced, that pops the whole RHP to the underlying report.Fix: In
useParticipantSubmission.goToNextStep, pass an explicitbackTo(the recipient-picker route, viaNavigation.getActiveRoute()) when building the confirmation route. This is now keyed onisMovingTransactionFromTrackExpense && !isCategorizing(i.e. theSUBMITandSHARE"moving a tracked expense" actions, excludingCATEGORIZEwhich routes through the category step), reusing the exact mechanism already used for theSHAREaction, so the confirmation back button takes theif (backTo)branch and returns to the recipient list. Global-create, categorize, split, and pay flows are untouched. The same fix also covers the Inbox track-expense whisper's "Submit it to someone" flow, which shares this code path.Fixed Issues
$ #99145
PROPOSAL:
Tests
Prerequisite: the account has a Self DM.
Offline tests
Same as Tests. The fix only changes client-side navigation, so the back-button behavior is identical while offline.
QA Steps
Same as Tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari