Repository navigation
Wait for navigation readiness before redirecting from the money request start page - #101221
Conversation
…request start page Co-authored-by: Bruno Rocha <brunovjk@users.noreply.github.com>
Co-authored-by: Bruno Rocha <brunovjk@users.noreply.github.com>
|
🤖 Android test steps verification results: ✅ pass On standalone Android NewDot, all 4 cold-launched money-request deeplinks land on their correct start pages (not Spend > Expenses), and the in-app FAB / quick-action paths for Create expense, Scan, and Track distance are unaffected. Notes: genuine cold launches were produced by force-stopping the app and then firing the deeplink intent ( view run · no recording available |
|
🤖 Web test steps verification results: The in-app entry points (FAB → Create expense, and the Scan receipt / Track distance quick actions) work as expected on dev NewDot web. The four cold-load deeplink steps — the ones that actually exercise this fix — could not be run: my web test harness has no way to perform a genuine full-page navigation without dropping client auth and landing on the sign-in wall. That is an environment limitation, not a failure of the change. This is the same blocker noted in the PR body.
Notes:
view run · no recording available |
|
@MelvinBot I made those tests (Please update the PR description with them): But I landed on a "Not found" page after visiting the link Screen.Recording.2026-09-18.at.11.44.11.mov |
|
Done — PR description updated with your steps in Heads up on the steps themselves: The two things in your report are different1. 2.
This is exactly the follow-up called out in the issue, and the same Not found What I'd suggestThe readiness fix in this PR is correct and testable on its own via One gapI couldn't re-verify the cold loads on web myself. My web harness can't perform a genuine full-page navigation mid-session (CI owns the browser session; reloading drops client auth), so the four cold-load steps are still unverified on web. All four were verified on Android native in the earlier run on this PR. Everything above is from reading the code at |
|
@MelvinBot Since |
|
Hey @arosiclair, about the What do you think we should do here — include the fix in this PR, or open a follow-up issue for the deprecated |
…tion is ready Co-authored-by: Bruno Rocha <brunovjk@users.noreply.github.com>
|
Yes — good catch, added in The concrete risk is I used the One non-obvious line: the cleanup also resets TestsNew regression test
|
|
🤖 There's nothing to fix in the code — every code check on this PR is green. The only failing check is Check independent approval, and it fails at its Full check statusAll 30+ code checks pass, including:
The failing job is To unblock: have a reviewer approve the PR. Since I authored it, your approval as assignee may not satisfy the independent-approval rule — if it doesn't, a second Expensify engineer needs to review. I could not verify anything in a browser on this run — the web test environment failed to come up, so this analysis is from the CI logs and check statuses alone. |
If we can fix both issues without a big increase in scope, then let's try to fix them both here. |
Can we do this here, @MelvinBot? Thanks. |
… the start page Co-authored-by: Bruno Rocha <brunovjk@users.noreply.github.com>
|
Yes — done in What was broken: The fix: One thing to confirm before QA: PR description is updated: the "expected to still fail by design" note is gone, steps 1-4 now have a real expected result, and steps 9-11 cover both aliases. TestsTwo new tests in the redirect page suite (
|
|
🤖 Re-checked after a fresh full CI run completed. The conclusion is unchanged, and there is still nothing to fix in code — so I pushed nothing. Final tally on the current head ( The one failure is Check independent approval, at its DetailWhen I looked last time, several jobs were still pending. They have all since finished, all green — including Failing job:
To unblock: this needs a reviewer approval. Because I ( I could not verify anything in a browser on this run — the web test environment failed to start, so this is from CI logs and check statuses alone. |
|
It worked well in the initial test; I'll do the full review a bit later. |
|
@arosiclair, could you help me confirm one expected behavior? After being redirected to Screen.Recording.2026-09-28.at.12.01.07.mov |
|
I think that behavior is fine since we are reloading the app entirely when we enter a URL in the address bar like that. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp101221_android_native.movAndroid: mWeb Chrome101221_web_native.moviOS: HybridApp101221_ios_native.moviOS: mWeb Safari101221_ios_web.movMacOS: Chrome / Safari101221_web_chrome.mov |
|
Great work @MelvinBot, everything looks good to me and passes the tests. Please fill out the entire author checklist—you can use my screenshots/videos above—and then open the PR for review. Thanks. |
|
Thanks
Next step: someone with write access needs to click Ready for review on this PR. |
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Good for product.
|
@MelvinBot implement the fix in this comment and the conflicts in this PR. Thanks. |
…stColdLoadNavigation Co-authored-by: Bruno Rocha <brunovjk@users.noreply.github.com> # Conflicts: # tests/ui/IOURequestRedirectToStartPageTest.tsx
Co-authored-by: Bruno Rocha <brunovjk@users.noreply.github.com>
|
@arosiclair 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] |
|
I fixed the em dash comment and resolved the merge conflict with
Checks run locally
|
|
MelvinBot has made 6 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
arosiclair
left a comment
There was a problem hiding this comment.
Many of these comments are overly verbose or unnecessary
| // Wait for the NavigationContainer before touching navigation. On a cold load (this route pasted into the | ||
| // address bar) this effect runs while the container is still initializing, and the dismiss and the redirect | ||
| // are then deferred through two different mechanisms: navigate() parks the route in `pendingNavigationCall` | ||
| // while dismissModal() queues itself on the navigation-ready promise. setIsNavigationReady() drains the | ||
| // pending route first and resolves the promise second, so the new modal is pushed and then immediately | ||
| // dismissed, dropping the user on the fullscreen page behind it instead of the start page. Running both | ||
| // inside one isNavigationReady() callback keeps them in the intended order: dismiss, then redirect. |
There was a problem hiding this comment.
| // Wait for the NavigationContainer before touching navigation. On a cold load (this route pasted into the | |
| // address bar) this effect runs while the container is still initializing, and the dismiss and the redirect | |
| // are then deferred through two different mechanisms: navigate() parks the route in `pendingNavigationCall` | |
| // while dismissModal() queues itself on the navigation-ready promise. setIsNavigationReady() drains the | |
| // pending route first and resolves the promise second, so the new modal is pushed and then immediately | |
| // dismissed, dropping the user on the fullscreen page behind it instead of the start page. Running both | |
| // inside one isNavigationReady() callback keeps them in the intended order: dismiss, then redirect. |
| // The page can be gone by the time the container is ready. dismissModal() tears down whatever modal is on | ||
| // top, so replaying this after the user left would dismiss a modal we never opened and push the start page | ||
| // over it. |
There was a problem hiding this comment.
| // The page can be gone by the time the container is ready. dismissModal() tears down whatever modal is on | |
| // top, so replaying this after the user left would dismiss a modal we never opened and push the start page | |
| // over it. |
| }); | ||
|
|
||
| return () => { | ||
| isCancelled = true; |
There was a problem hiding this comment.
| isCancelled = true; | |
| // This page is getting unmounted so we cancel any navigation effects | |
| isCancelled = true; |
| // Release the once-only guard so a remount can schedule the redirect this cleanup just cancelled. A real | ||
| // unmount throws the ref away with the instance, so this only matters when the same instance is cleaned up | ||
| // and immediately remounted (StrictMode does that to effects in dev). |
There was a problem hiding this comment.
| // Release the once-only guard so a remount can schedule the redirect this cleanup just cancelled. A real | |
| // unmount throws the ref away with the instance, so this only matters when the same instance is cleaned up | |
| // and immediately remounted (StrictMode does that to effects in dev). |
| * `request` and `send` are deprecated OldDot aliases of `submit` and `pay`. They still arrive from old links, and | ||
| * `isValidMoneyRequestType` still accepts them, but the create flow rejects them: `withWritableReportOrNotFound` | ||
| * filters both out of the valid iouType list, so any create route built with one renders "Not found". Resolve an | ||
| * alias to the type NewDot actually renders before building a route with it. |
There was a problem hiding this comment.
| * `request` and `send` are deprecated OldDot aliases of `submit` and `pay`. They still arrive from old links, and | |
| * `isValidMoneyRequestType` still accepts them, but the create flow rejects them: `withWritableReportOrNotFound` | |
| * filters both out of the valid iouType list, so any create route built with one renders "Not found". Resolve an | |
| * alias to the type NewDot actually renders before building a route with it. | |
| * `request` and `send` are deprecated OldDot aliases of `submit` and `pay`. This resolves an | |
| * alias to the type NewDot actually renders before building a route with it. |
|
@MelvinBot, could you address the comments raised by arosiclair in your latest review? Thanks. |
Co-authored-by: Bruno Rocha <brunovjk@users.noreply.github.com>
|
I applied all 5 of
ESLint passes on both files. I didn't rerun the Jest tests in this run. CI will run them. I left the comments in the test file as they are, because the review didn't flag them. Tell me if you want those trimmed too. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 arosiclair 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/arosiclair in version: 9.5.4-0 🚀
|
|
No help site update needed. This PR fixes |
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.5.4-3 🚀
Bundle Size Analysis (Sentry): |











Explanation of Change
Opening a
/start/:iouType/:iouRequestTypedeeplink (for example/start/create/manual) straight from the address bar is a cold load, soIOURequestRedirectToStartPagemounts and runs its redirect before theNavigationContaineris ready. The two navigation calls it makes were then deferred through two different mechanisms:Navigation.navigate(...)(viastartMoneyRequest/startDistanceRequest) parks the route inpendingNavigationCall.Navigation.dismissModal()queues itself on the navigation-ready promise.setIsNavigationReady()drains the pending route first and resolves the promise second:So on a cold load the create modal was pushed and immediately dismissed, leaving the user on the fullscreen background the deeplink places under the modal — the Spend > Expenses list ("No expenses yet"). In-app navigation reached this page with the container already ready, so dismiss-then-navigate ran in the correct order and the modal stayed open, which is why the bug only reproduced on cold/address-bar loads.
The fix: wrap the dismiss and the redirect branch selection in a single
Navigation.isNavigationReady().then(...). Both then run synchronously, in the intended order (dismiss, then push), after the container is ready — identical to the known-good warm path, and matching the pattern the sibling utility pageSubmitExpensePagealready uses. Because that makes the redirect async, the effect cleanup cancels the queued callback if the page unmounts first, so a latedismissModal()cannot tear down a modal this page never opened.Navigation.dismissModal()is kept as-is (not swapped forgoBack()): it dispatchesDISMISS_MODAL, tearing down the whole RHP, which preserves the original "there shouldn't be two modals stacked" intent.goBack()pops a single screen and is what could leave stale modal history. The only load-bearing change is the readiness guard.clearMoneyRequest(...)stays outside the callback — it is an Onyx write, not a navigation call, and it must still run once on mount.Second fix — the deprecated
requestalias. With only the readiness fix,/start/request/manualopened the create modal and then dead-ended on "Not found".requestandsendare deprecated OldDot aliases, andwithWritableReportOrNotFoundfilters both out of the valid iouType list, so any create route built with one renders "Not found" — this is also the in-chat-link "Not found"arosiclairspotted on the issue.IOUUtilsalready resolved those aliases (request → submit,send → pay), but only insidenavigateToParticipantPage. That switch is now the exportedgetNonDeprecatedIOUType, and this page calls it before building the redirect route — the one place every/start/…link passes through. Resolving at the edge keeps the deprecated types out of the create flow entirely, rather than teaching the flow to accept them.Why
submitand notcreate:requestis paired withsubmiteverywhere else in the code —getMoneyRequestOptionsadds it alongsidesubmit,MoneyRequestAmountFormtreats the two identically, andnavigateToParticipantPagealready mapped it that way.createis the unified FAB entry point, not an alias. One consequence to know before QA: the submit flow asks for a recipient before the amount, so/start/request/manualnow lands on "Choose recipient" rather than the amount keypad, exactly like/start/submit/manual. Say the word if you would ratherrequestresolve tocreate(amount-first) — it is a one-word change ingetNonDeprecatedIOUType.AI Tests
Ran locally against the changed files:
npm run test -- tests/ui/IOURequestRedirectToStartPageTest.tsx tests/unit/IOUUtilsTest.ts tests/unit/QuickActionNavigationTest.ts tests/unit/QuickActionMenuItemTest.tsx tests/unit/DefaultP2PMileageRateTest.ts tests/ui/components/SearchActionsBarCreateButtonTest.tsx tests/navigation/getMatchingFullScreenRouteTests.ts— 181/181 pass.isNavigationReady()wrapper (dismissModalruns while the container is still initializing), the unmount test fails without theisCancelledcheck, and the two alias tests fail withoutgetNonDeprecatedIOUType(the route is built withrequest/send).npm run typecheck— pass.npm run react-compiler-compliance-check -- check src/pages/iou/request/IOURequestRedirectToStartPage.tsx— pass.npx eslinton each changed file — pass.tests/unit/IOUUtilsTest.tsreports oneno-restricted-importserror on its line 13 import, which is pre-existing, untouched by this PR, and covered by the lint seatbelt.Not run:
npm run lint-changedandnpm run spell-changed(both resolve amainmerge-base that this checkout does not have — ESLint was run per file instead),npm run storybook -- --smoke-test --ci, and the fullnpm testsuite. Noprettierscript exists in this repo; formatting is enforced through ESLint, which passed.Browser verification could not be completed in this environment: exercising the bug requires a genuine cold load (a full page navigation), which drops client auth in the automated web session and lands on the sign-in wall. The behavior is covered by unit tests instead, which assert the deferral, the dismiss-before-navigate ordering, the unmount guard, and the deprecated-alias resolution. All four cold-load deeplinks were verified on Android native — see the MelvinBot test comment on this PR. The deprecated-alias fix has unit coverage only; it has not been driven in a browser.
Update: The reviewer (
brunovjk) has since tested this PR on all platforms and confirmed the tests pass. See the recordings in the Screenshots/Videos section below.Fixed Issues
$ #99329
PROPOSAL: #99329 (comment)
Tests
Reported repro (from the linked issue):
/start/request/manual(for examplehttps://staging.new.expensify.com/start/request/manual)./start/submit/manual, becauserequestnow resolves tosubmit.Cold-load deeplinks fixed by this PR:
/start/create/manualinto the address bar and press Enter. Verify the Manual amount entry page opens, not Spend > Expenses./start/submit/manualand verify the Submit expense flow opens (recipient step first), not Spend > Expenses./start/create/scanand verify the Scan receipt start page opens./start/create/distanceand verify the Track distance start page opens.Deprecated alias links fixed by this PR:
https://staging.new.expensify.com/start/request/manualas a message in any chat, then click the link. Verify the expense creation flow opens (recipient step first) instead of a "Not found" page./start/send/manualand verify the Pay someone flow opens./start/request/manualinto the address bar and press Enter. Verify the same flow opens on a cold load — not Spend > Expenses, and not "Not found".No regression to the in-app entry points:
Note
Step 1-4 and step 9 land on "Choose recipient", not the amount keypad — that is the expected result.
requestresolves tosubmit, and the submit flow asks who the expense is for before it asks how much./start/create/manual(step 5) is the amount-first flow.Offline tests
This change only reorders two client-side navigation calls and makes no API request, so the offline behavior of the deeplink is unchanged.
/start/create/manualinto the address bar and press Enter.QA Steps
Same as tests, using
https://staging.new.expensify.cominstead of the dev URL. Note the callout in theTestssection:/start/request/manualopens the submit flow, so it asks for a recipient before the amount — that is the expected result, not a failure.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
101221_android_native.mov
Android: mWeb Chrome
101221_web_native.mov
iOS: Native
101221_ios_native.mov
iOS: mWeb Safari
101221_ios_web.mov
MacOS: Chrome / Safari
101221_web_chrome.mov