Skip to content

Restore the pre-inserted tab route by key on cancel - #105857

Merged
mountiny merged 2 commits into
Expensify:mainfrom
mukhrr:fix/103777
Nov 5, 2026
Merged

mountiny merged 2 commits into
Expensify:mainfrom
mukhrr:fix/103777

Conversation

@mukhrr

@mukhrr mukhrr commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Cancelling a tab pre-inserted under the RHP wrote the saved tab route over the last TabNavigator by name, so when the RHP had opened another TabNavigator since, two root routes ended up with the same key and the top RHP crashed on a tab state. The restore now finds the saved route by its key and puts it back in its own slot.

Fixed Issues

$ #103777
PROPOSAL: #103777 (comment)

Tests

Precondition: the account has a restricted workspace (it shows "Add a payment card").

  1. Tap the FAB > Create expense, switch to the Manual tab and wait about 1 second.
  2. Choose the restricted workspace, then tap Go to Subscription.
  3. Tap the magnifying glass at the top right of the Subscription page.
  4. Type type:expense and submit it.
  5. Tap the FAB > Create expense, go back out of the workspace picker, then tap the Scan tab (or tap the Scan receipt quick action if the FAB has one).
  6. Verify the app does not crash and the Scan camera screen opens.
  7. Close the RHP and tap the FAB > Create expense > Manual, then go back.
  8. Verify the RHP closes and you are back on the tab you started from.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests while offline. The change is a client-side navigation state update with no network calls, so the result is the same offline and online.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged the Expensify/design team so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.app.mp4
Android: mWeb Chrome
android.web.mp4
iOS: Native
ios.app.mp4
iOS: mWeb Safari
ios.web.mp4
MacOS: Chrome / Safari
web.mp4

handleRemoveFullscreenUnderRHP wrote the saved tab route over the last
TAB_NAVIGATOR found by name. When the RHP had opened another fullscreen
tab since the pre-insert, that overwrote the newer tab, leaving two root
routes with the same key and handing the top RHP a tab navigator state,
which crashed in getStateForRouteNamesChange.

The pre-insert keeps the original tab route key, so look the slot up by
that key instead.
@mukhrr
mukhrr requested review from a team as code owners November 4, 2026 05:12
@melvin-bot
melvin-bot Bot requested review from QichenZhu and removed request for a team November 4, 2026 05:12
@melvin-bot

melvin-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

@QichenZhu 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]

@melvin-bot
melvin-bot Bot requested a review from dylanexpensify November 4, 2026 05:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T05:26:14.808205Z 371799c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

revertPreMountBufferIfRHPClosed and recoverFromPreMountBuffer had the same
last-TAB_NAVIGATOR-by-name lookup as handleRemoveFullscreenUnderRHP, so a tab
pushed after the pre-insert could be overwritten by the saved route.

The two existing tab-restore tests now use the key the pre-insert keeps and
assert on the captured route, since the mocked clear made them compare
undefined with undefined.

@dylanexpensify dylanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

product input not required

@QichenZhu

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
    https://expensify.slack.com/archives/C049HHMV9SM/p1764642854883869
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen_recording_20261105_072055.webm
Android: mWeb Chrome
Screen_recording_20261105_072841.webm
iOS: HybridApp
Simulator.Screen.Recording.-.iPhone.17.-.2026-11-05.at.07.18.46.mov
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.17.-.2026-11-05.at.07.42.23.mov
MacOS: Chrome / Safari
Screen.Recording.2026-11-05.at.7.46.48.AM.mov

@QichenZhu

Copy link
Copy Markdown
Contributor

NAB: on mobile web, after tapping Add payment card, the background screen sometimes switches to Spend. Same on staging.

Screen_recording_20261105_084750.webm

@melvin-bot
melvin-bot Bot requested a review from mountiny November 4, 2026 19:50
@mukhrr

mukhrr commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

NAB: on mobile web, after tapping Add payment card, the background screen sometimes switches to Spend. Same on staging.

Screen_recording_20261105_084750.webm

yeah i think this is out of scope for this PR.
@mountiny do you think we can open a new issue for this?

@mountiny

mountiny commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot can you check if there is an issue for #105857 (comment) and create it if not? can you also analyze if this is a regression from some recent pr?

@mountiny
mountiny merged commit 6a1b6f8 into Expensify:main Nov 5, 2026
37 of 41 checks passed
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot

Copy link
Copy Markdown
Contributor

Found an existing open issue: Trial ended—User is not navigated to Subscription page after clicking Add payment card. It covers the same restricted-workspace button opening the card form over the wrong background. I haven’t created a duplicate. The exact intermittent mobile-web Spend switch is not independently confirmed as the same bug.

Proposal

What is the root cause of that problem?

Likely a regression from Keep the page an RHP was opened from underneath it, merged October 27. That PR changed this button from a fixed Subscription destination to a dynamic route based on the active page after modal dismissal. Consequently, the card form no longer necessarily opens over Subscription.

Code evidence and the Spend-specific uncertainty

What changes do you think we should make in order to solve the problem?

For this restricted-workspace entry point, explicitly anchor the card form to Subscription, preserving the intended return navigation. Keep dynamic backgrounds for other entry points. Cover both Inbox and Spend starting contexts, including closing the form.

What alternative solutions did you explore? (Optional)

This is unlikely to originate in this PR: the original report reproduced it on staging before this PR merged. A separate transient pre-insert cleanup bug remains possible; distinguish that from the already-tracked wrong destination before opening another issue.

Verification: The web check was blocked by a blank page. Attribution of the exact Spend symptom remains medium confidence, not runtime-proven.


Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/105225) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.

@OSBotify OSBotify mentioned this pull request Nov 6, 2026
93 tasks done
@OSBotify

OSBotify commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.33-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No FullStory changes needed. This PR only fixes tab-route restoration to prevent a navigation crash and adds regression tests, without introducing new UI, screens, user-property values, or sensitive content.

@OSBotify

OSBotify commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.5.33-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants