Repository navigation
[CP Stg] Treat /Home deeplink route as empty to prevent not-found page - #91022
Conversation
Add isAuthenticated guard to the hasCompletedGuidedSetupFlowSelector check to prevent handleDeeplinkNavigation from being called before login completes. The selector returns true for empty onboarding objects, which caused premature navigation during the sign-in flow. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
| }; | ||
|
|
||
| if (hasCompletedGuidedSetupFlowSelector(val) || isAnonymousUser()) { | ||
| if ((isAuthenticated && hasCompletedGuidedSetupFlowSelector(val)) || isAnonymousUser()) { |
There was a problem hiding this comment.
@MelvinBot add comment.
And if possible, add automated tests to prevent this bug further.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Add an inline comment in Link.ts explaining why the isAuthenticated check is needed before hasCompletedGuidedSetupFlowSelector (the selector returns true for empty onboarding objects, which is the pre-login default state). Add a regression test in OnboardingSelectorsTest.ts that documents this behavior and verifies the combined deeplink guard condition rejects unauthenticated users even when the selector returns true. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Done! Pushed two changes:
Note: A full integration test for |
|
@MelvinBot fill out QA Steps and all items in checklist |
|
Updated the PR body with: QA Steps: Sign in via magic code and verify no "Hmm...it's not here" page, test deeplinks while authenticated, and test anonymous access to public rooms. Checklist: Checked all applicable items, marked N/A for items not relevant to this one-line guard condition change (no UI changes, no new files, no copy/localization, no CSS, etc.). Still needs human verification:
|
| // We must check isAuthenticated before hasCompletedGuidedSetupFlowSelector because the selector | ||
| // returns true for empty onboarding objects (the pre-login default state), which would cause | ||
| // premature deeplink navigation before authentication completes. | ||
| if ((isAuthenticated && hasCompletedGuidedSetupFlowSelector(val)) || isAnonymousUser()) { |
There was a problem hiding this comment.
@MelvinBot unfortunately below test is failing:
- Logout
- Deep link to /concierge
- Login with existing account
Expected: User is redirected to concierge chat
Actual: Keeps on Home page
The isAuthenticated parameter is captured at call time in openReportFromDeepLink and never updates after login. When a user deep links while logged out, isAuthenticated stays false in the closure even after waitForUserSignIn resolves, so the guard added in the previous commit always evaluated to false and handleDeeplinkNavigation was never called. Switch to hasAuthToken() which reads the current auth state dynamically, fixing the deep-link-then-login flow while still preventing premature navigation before authentication. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Good catch — this was a stale closure bug. The Fixed by switching to Please re-test with: Logout → Deep link to /concierge → Login → verify redirect to concierge chat. |
| // before hasCompletedGuidedSetupFlowSelector because the selector returns true for empty | ||
| // onboarding objects (the pre-login default state), which would cause premature deeplink | ||
| // navigation before authentication completes. | ||
| if ((hasAuthToken() && hasCompletedGuidedSetupFlowSelector(val)) || isAnonymousUser()) { |
There was a problem hiding this comment.
@MelvinBot adding hasAuthToken() condition doesn't fix linked issue.
Please find solution to fix both #90880 and #82818
The hasAuthToken() guard didn't fix #90880 because the real problem is navigating to an empty route ('') when the user visits the root URL and signs in. After login, hasAuthToken() returns true, and the selector returns true for empty onboarding objects, so Navigation.navigate('') fires and shows "not found". The fix checks that route is truthy (non-empty) before allowing deeplink navigation for non-anonymous users. This prevents empty-route navigation (fixing #90880) while preserving deeplink-then-login flows like /concierge (preserving the #82818 fix from PR #85740). Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
You're right — Root cause: When a user visits the root URL ( Fix: Replaced - if ((hasAuthToken() && hasCompletedGuidedSetupFlowSelector(val)) || isAnonymousUser()) {
+ if ((route && hasCompletedGuidedSetupFlowSelector(val)) || isAnonymousUser()) {This fixes both issues:
Updated the regression test to verify both scenarios. All 12 tests pass. |
| // empty route when the user visits the root URL (e.g. new.expensify.com) and then signs in. | ||
| // Without this, hasCompletedGuidedSetupFlowSelector returns true for empty onboarding objects | ||
| // and Navigation.navigate('') fires, showing a "not found" page. | ||
| if ((route && hasCompletedGuidedSetupFlowSelector(val)) || isAnonymousUser()) { |
There was a problem hiding this comment.
@MelvinBot route is Home (when logged out), not empty so still not fixing bug
|
You're right — the Updated fix: Changed the guard from if ((route && hasCompletedGuidedSetupFlowSelector(val)) || isAnonymousUser()) {Why this works: When a user visits the root URL ( The test in |
|
@MelvinBot the not found page bug happens becuase user is navigated to |
|
The capitalized The problem is that the However, I'd caution against changing The right fix would likely be either:
Both approaches touch navigation infrastructure and carry risk. Would you like me to implement one of these, or do you have a preferred approach? |
@MelvinBot let's try this |
|
|
@MelvinBot let's try this |
React Navigation generates /Home (capitalized) for the sign-in page because
PublicScreens uses SCREENS.HOME ('Home') at the root level without a path
mapping. This causes a "not found" page when navigating to /Home after login.
Normalize the path to lowercase when it case-insensitively matches /home,
following the same pattern as the existing /signin normalization.
Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Done! Added path normalization in Note: I wasn't able to run prettier locally due to missing dependencies, so CI will validate formatting. If it fails, I'll fix it. |
|
MelvinBot has made 5 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. |
| if (normalizedPath.toLowerCase() === `/${ROUTES.HOME}`) { | ||
| normalizedPath = `/${ROUTES.HOME}`; | ||
| } | ||
|
|
There was a problem hiding this comment.
@MelvinBot revert this change. Still doesn't fix "not found page".
Instead let's treat "/Home" as empty route in Link.ts
Reverts the route truthiness guard and getAdaptedStateFromPath normalization. Instead, normalizes the /Home route to empty string early in openReportFromDeepLink, matching the existing pattern for /signin route handling. This prevents the "not found" page when React Navigation generates /Home for the root URL. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Done! Reverted the previous approach and implemented the Changes:
Updated PR title and description to match. |
|
|
||
| // React Navigation generates /Home (capitalized) for the root URL because PublicScreens uses SCREENS.HOME ('Home') | ||
| // at the root level without a path mapping. Treat it as empty route to avoid showing a “not found” page after sign-in. | ||
| if (normalizePath(route).toLowerCase() === `/${ROUTES.HOME}`) { |
There was a problem hiding this comment.
@MelvinBot to avoid conflict with authorized home route, compare directly with Home or SCREENS.HOME
There was a problem hiding this comment.
Done — changed to compare directly with SCREENS.HOME ('Home') instead of lowercasing and comparing with ROUTES.HOME ('home').
|
@mkhutornyi 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] |
|
@roryabraham looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
🚧 @roryabraham 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! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
…tionBeforeAuth [CP Stg] Treat /Home deeplink route as empty to prevent not-found page (cherry picked from commit a23fdff) (cherry-picked to staging by roryabraham)
|
🚀 Cherry-picked to staging by https://github.com/roryabraham in version: 9.3.75-14 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes required. This PR is an internal bug fix for deeplink navigation timing logic ( |
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.3.75-14 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Cherry-picked to staging by https://github.com/roryabraham in version: 9.3.76-0 🚀
|
|
No help site changes are required for this PR. This is an internal bug fix that adds an |
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.3.77-3 🚀
|
Explanation of Change
Regression from #85740. That PR added a
hasCompletedGuidedSetupFlowSelector(val)check to guardhandleDeeplinkNavigation(), but the selector returnstruefor empty onboarding objects (which is the default state before onboarding data loads). When a user visits the root URL (new.expensify.com) and signs in,getRouteFromLink()returns''(empty string). The selector passes,handleDeeplinkNavigation()fires, andNavigation.navigate('')shows a "Hmm...it's not here" page.The fix normalizes the
/Homeroute (generated by React Navigation for the root URL) to an empty string early inopenReportFromDeepLink, following the same pattern used for the/signinroute. This prevents deeplink navigation from firing with a route that doesn't exist in the app.Fixed Issues
$ #90880
PROPOSAL: #90880 (comment)
Tests
// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
// Please describe what tests you performed that validates your changed worked.
Offline tests
// TODO: The human co-author must fill out offline tests before marking this PR as "ready for review"
QA Steps
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