Skip to content

Keep the current tab when opening an exitTo link from a signed-in val… - #101335

Merged
mollfpr merged 2 commits into
Expensify:mainfrom
yusufdeveloper2903:fix-100680-exitto-keep-tab
Sep 23, 2026
Merged

mollfpr merged 2 commits into
Expensify:mainfrom
yusufdeveloper2903:fix-100680-exitto-keep-tab

Conversation

@yusufdeveloper2903

@yusufdeveloper2903 yusufdeveloper2903 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

When a signed-in user opens a report link from an email while the app is on another tab, handleExitToNavigation called goBack(ROUTES.HOME), which switched the tab to Home before the report was opened. Now only ValidateLogin is popped when there is a screen under it, so the report opens on the current tab. goBack(ROUTES.HOME) is still used when ValidateLogin is the only route.

Added unit tests in tests/navigation/HandleExitToNavigationTests.tsx.

Fixed Issues

$ #100680
PROPOSAL: #100680 (comment)

Tests

Precondition: As submitter, submit an expense report so the workspace owner receives the email.

  1. As WS owner, open the app and go to Inbox
  2. Background the app and open the email from the precondition
  3. Tap View
  4. Verify the app opens the report
  5. Go to the Spend tab and repeat steps 2-4
  • Verify that no errors appear in the JS console

Offline tests

N/A

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 followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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 followed the guidelines as stated in the Review Guidelines
  • 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 a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • 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 @Expensify/design so the design team can review the changes.
  • 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 AFTER FIX:
REC-20260916180935.mp4
Android: mWeb Chrome
iOS: Native

AFTER FIX:

REC-20260922124122.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari

@yusufdeveloper2903
yusufdeveloper2903 requested review from a team as code owners September 16, 2026 13:37
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and QichenZhu and removed request for a team September 16, 2026 13:37
@melvin-bot

melvin-bot Bot commented Sep 16, 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 removed the request for review from a team September 16, 2026 13:37

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ab422bc42

ℹ️ 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".

Comment thread src/libs/actions/Session/index.ts Outdated

@JmillsExpensify JmillsExpensify 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.

LGTM

Navigation.waitForProtectedRoutes().then(() => {
Navigation.goBack(ROUTES.HOME, {waitForTransition: true});
if (navigationRef.canGoBack()) {
Navigation.pop(navigationRef.getRootState().key);

@QichenZhu QichenZhu Sep 21, 2026 •

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.

I'm not questioning it, just curious why you went with this approach instead of your original proposal. In what scenario would these two approaches behave differently, so I can test it?

@yusufdeveloper2903 yusufdeveloper2903 Sep 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Short answer on why I moved off my proposal's line.

goBack(undefined) doesn't always pop ValidateLogin. When shouldPopToSidebar is set, goBack takes the popToSidebar() branch first, and popToSidebar() clears the flag and returns without popping anything, because the top root route is ValidateLogin and not a split navigator. NavigationRoot sets that flag on any wide → narrow change while a split navigator is on top (e.g. rotating landscape → portrait with a report open), and it stays set until the next parameterless goBack().

I ran both versions through the real navigators in Jest with the flag set. The report opens on the right tab either way, so the fix for this issue holds in both, but the resulting root stack differs:

  • this PR: [TabNavigator → Inbox split: Inbox, Report]
  • my original line: [TabNavigator(Inbox), ValidateLogin, TabNavigator(Inbox split: Report)]

So with the proposal's line the consumed ValidateLogin stays in the stack and the report is pushed above it in a second tab navigator: Back from the report shows the /v/ loading screen, and only the second Back returns to the report list.

Navigation.pop(navigationRef.getRootState().key) is dispatched at the root stack directly, so the flag can't redirect it and the only route it can remove is ValidateLogin. The lone-route case is unchanged: still goBack(ROUTES.HOME, {waitForTransition: true}). This is covered by removes ValidateLogin even when a pop to sidebar is pending — it fails with my original line (Expected: false Received: true) and passes with this one.

@QichenZhu

QichenZhu commented Sep 22, 2026 •

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/p1790051358940179
    https://expensify.slack.com/archives/C049HHMV9SM/p1764642854883869
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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 that this PR follows the guidelines as stated in the Review Guidelines
  • 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 a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • 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.
  • 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_20260922_163527.webm
Android: mWeb Chrome
Screen_recording_20260922_164025.webm
iOS: HybridApp
Screen.Recording.2026-09-22.at.4.34.40.PM.mov
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.17.-.2026-09-22.at.16.14.34.mov
Simulator.Screen.Recording.-.iPhone.17.-.2026-09-22.at.16.22.40.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-22.at.4.44.00.PM.mov

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

Thanks! Please record the iOS video. You can test the direct link in the Simulator by running xcrun simctl openurl booted "new-expensify://v/22983538/MZUDTGTRV?exitTo=/r/1848836441519490". Replace the URL with the one from the email.

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

Thanks @QichenZhu Added the iOS Native video using the simctl openurl approach — it covers both the Inbox and the Spend tab.

@melvin-bot
melvin-bot Bot requested a review from mollfpr September 22, 2026 10:35
@mollfpr
mollfpr merged commit e750762 into Expensify:main Sep 23, 2026
36 of 41 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

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.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mollfpr in version: 9.4.92-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required for this PR, so I did not create a docs draft PR.

This PR is a navigation bug fix, not a product change. It swaps goBack(ROUTES.HOME) for a pop of the ValidateLogin route when a screen sits under it, in src/libs/actions/Session/index.ts:1603-1607, plus a new unit test file. The only other file touched is tests/navigation/HandleExitToNavigationTests.tsx.

It restores the behavior users already expect — tapping View in an email opens the report — rather than introducing new behavior. Nothing user-facing changed: no new feature, no new or renamed setting, no new button, tab, or label.

How I checked the help site

I searched docs/articles for the topics this PR could touch:

No article states the old (buggy) behavior, so there is no stale text to correct and no gap to fill. Writing a new article about it would document an implementation detail, which the help authoring guidelines do not call for.

One caveat: browser control was unavailable in this run, so I could not verify the fix live in NewDot web. The conclusion above comes from reading the diff, the linked issue, and the help site markdown.

Since there is no docs PR, there is nothing to label HelpDot, assign, or mark Ready for review. If you disagree and want an article added or updated anyway, reply with @MelvinBot and the article you have in mind, and I'll draft it.

yusufdeveloper2903, please confirm you agree that no help site update is needed here.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.92-8 🚀

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