[No QA] Fix onboarding modal guard redirect causing infinite navigation loop#86856
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@linhvovan29546 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01b2294efc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const existingRouteNames = new Set(state.routes.map((route) => route.name)); | ||
| const newRoutes = redirectState.routes.filter((route) => !existingRouteNames.has(route.name)); | ||
| resetRoutes = [...(state.routes as typeof redirectState.routes), ...newRoutes]; |
There was a problem hiding this comment.
Preserve updated modal route state during redirect
When isModalRedirect is true, the merge path drops any redirect route whose name already exists (existingRouteNames), so an existing ONBOARDING_MODAL_NAVIGATOR/MIGRATED_USER_MODAL_NAVIGATOR entry is never replaced with the new redirectState version. That makes guard redirects a no-op when only the nested state/params changed (same route name), even though guards like OnboardingGuard compute a step-specific redirect route repeatedly. In that case users can remain on a stale onboarding step because resetRoutes reuses state.routes instead of applying the newly computed modal route state.
Useful? React with 👍 / 👎.
|
Closing in favor of #86390 |
Explanation of Change
When a navigation guard redirects to a modal route (e.g.
OnboardingModalNavigatororMigratedUserModalNavigator), theREDIRECThandler inRootStackRouter.tswas callingCommonActions.reset()with only the redirect state's routes. This wiped out all existing base app routes (likeReportsSplitNavigator).With no base routes present, React Navigation continuously generated
PUSHactions to reconcile the missing routes — creating an infinite loop.The fix detects whether the redirect target is a modal navigator. If it is, the redirect routes are merged with the existing state routes instead of replacing them. Non-modal redirects (e.g. to
HOME) still perform a full replace as before.Fixed Issues
$ #85454
PROPOSAL:
Tests
@gmail.comdomainOffline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
Screen.Recording.2026-04-01.at.11.37.44.mov