Prevent LHN from remounting after navigating away from Inbox#83887
Prevent LHN from remounting after navigating away from Inbox#83887JS00001 merged 10 commits intoExpensify:mainfrom
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.
|
src/libs/Navigation/AppNavigator/usePreloadFullScreenNavigators.ts
Outdated
Show resolved
Hide resolved
|
@hungvu193 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: eb9c4e5c9a
ℹ️ 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 isRouteInStack = currentRoutes.some((r) => TAB_TO_FULLSCREEN[tabName].includes(r.name as FullScreenName)); | ||
|
|
||
| if (isRouteInStack) { | ||
| continue; |
There was a problem hiding this comment.
Limit stack-based skip to mounted navigators
This new isRouteInStack gate treats any route present in navigation.getState().routes as already mounted, but on Android I checked src/libs/Navigation/AppNavigator/createRootStackNavigator/useCustomRootStackNavigatorState/index.android.ts and previous full-screen routes are still sliced out when the previous route is also full-screen. In flows like Inbox → Workspaces, Inbox stays in the route state but is unmounted, so this condition skips preloadTab and forces Inbox to cold-mount again when switching back, reintroducing the tab-switch performance regression for Android users.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The cold-mount behavior on Android is tied to useCustomRootStackNavigatorState slicing and is not introduced or worsened by this change
| @@ -134,6 +134,7 @@ function usePreloadFullScreenNavigators() { | |||
| } | |||
| hasPreloadedRef.current = true; | |||
| setTimeout(() => { | |||
There was a problem hiding this comment.
I know this is not related, but why is this timer not getting cleared on unmount?
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-03-03.at.21.35.02.movScreen.Recording.2026-03-03.at.21.36.08.mov |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @JS00001 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! 🧪🧪
|
luacmartins
left a comment
There was a problem hiding this comment.
Nice! This is a great improvement
|
🚀 Deployed to staging by https://github.com/JS00001 in version: 9.3.31-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.31-12 🚀
|
|
🚀 Deployed to staging by https://github.com/JS00001 in version: 9.3.32-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.32-3 🚀
|
Explanation of Change
When navigating away from the Inbox screen to another full-screen navigator (e.g. a report), the
useCustomRootStackNavigatorStatehook was only keeping the last full-screen route and the one immediately before it if it was an RHP. This causedReportsSplitNavigator— which hosts the LHN — to get unmounted and remounted on every navigation away from Inbox.The fix simplifies the slicing logic to always keep the last two routes in the stack (i.e.
lastSplitIndex - 1), ensuring the previous full-screen navigator (likeReportsSplitNavigatorcontaining the LHN with its potentially thousands of items) stays mounted.Additionally,
usePreloadFullScreenNavigatorsnow skips preloading a tab's navigator if its full-screen route is already present in the regular navigation stack, avoiding duplicate mounting.Fixed Issues
$ #80560
$ #83950
$ #77174
$ #77175
PROPOSAL:
Tests
Web only
Offline 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-03-03.at.08.30.33.mov