You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-05-15] [Due for payment 2026-05-13] [$250] Switch flow - Page keeps on loading when click on Try New Expensify #89559
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
When a user switches to Expensify Classic from the Troubleshoot page and then clicks "Try New Expensify" in Classic, Classic redirects back to NewDot via a /transition?shortLivedAuthToken=xxx&exitTo=... URL. The user still has a valid session stored in IndexedDB from their previous NewDot session, so the app loads as authenticated and renders LogOutPreviousUserPage.
The bug is in isLoggingInAsNewUser: it receives the full transition URL (e.g. https://staging.new.expensify.com/transition?shortLivedAuthToken=xxx) and passes it directly to new URLSearchParams(). Since URLSearchParams expects only a query string — not a full URL — the first parameter key is mangled (becomes https://staging.new.expensify.com/transition?shortLivedAuthToken instead of shortLivedAuthToken). More importantly, the transition URL from Classic does not contain an email parameter, so both params.get('email') and the regex fallback return null. The function then evaluates null !== sessionEmail → true, incorrectly concluding the user is "logging in as a new user".
This triggers signOutAndRedirectToSignIn, which calls the server-side LogOut API via makeRequestWithSideEffects and waits for it to resolve before calling redirectToSignIn. During this wait, the user sees FullScreenLoadingIndicator. After sign-out completes, the user lands on LogInWithShortLivedAuthTokenPage, re-authenticates with the token, returns to LogOutPreviousUserPage, hits the same isLoggingInAsNewUser → true condition, and signs out again. The second time through, getLastShortAuthToken() prevents re-authentication, and the user either gets stuck on a loading indicator or lands on SessionExpiredPage — neither of which is the expected behavior (the app should just load normally since it's the same user).
What changes do you think we should make in order to solve the problem?
In LogOutPreviousUserPage, the isLoggingInAsNewUser check should be skipped when the transition URL has no email parameter at all. The absence of an email parameter means Classic didn't specify which user is transitioning — it simply means "continue as the current user." The function should only trigger a sign-out when a different email is explicitly present in the URL.
The fix should be in isLoggingInAsNewUser: if neither paramsEmail nor linkedEmail (from the regex fallback) is found in the URL, return false early — no email means no evidence of a different user.
What alternative solutions did you explore? (Optional)
Fix URLSearchParams parsing: Extract just the query string before passing to URLSearchParams (e.g., new URLSearchParams(new URL(transitionURL).search)). This would fix the parsing issue but wouldn't address the core problem that the transition URL lacks an email param entirely.
Have Classic include the email param: Modify the OldDot "Try New Expensify" redirect to include the user's email in the URL. This would make isLoggingInAsNewUser work correctly but requires a Classic-side change and doesn't fix the NewDot-side defensive gap.
Possibly related issue:#88243 — similar race condition with NVP_TRY_NEW_DOT and SESSION callback timing on mobile HybridApp
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
changed the title [-]Switch flow - Page keeps on loading when click on Try New Expensify[/-][+][$250] Switch flow - Page keeps on loading when click on Try New Expensify[/+]on May 4, 2026
Please re-state the problem that we are trying to solve in this issue.
After a user signs in to staging.new.expensify.com, goes to Account > Troubleshoot > Switch to Expensify Classic, and then clicks Try New Expensify from Expensify Classic, New Expensify should open normally. Instead, the New Expensify page stays on the loading screen and never finishes switching back into the New Expensify experience.
What is the root cause of that problem?
The handoff to Classic starts from the troubleshoot page.
For the web flow, the menu item either routes the user through the exit survey or, when the survey was completed recently, opens Classic immediately after starting switchToOldDot.
The final exit-survey confirmation is the normal path that flips the account back to Classic.
It has the same ordering problem: it calls switchToOldDot(exitSurveyResponse), dismisses the modal, and opens Classic in the same tab immediately afterward.
switchToOldDot starts the SwitchToOldDot write request but does not return or await it.
So both callers can navigate away from New Expensify before the write that sets the account back to Classic has finished.
That creates a race with the Try New Expensify button in Classic.
If the delayed SwitchToOldDot write completes after Classic starts the Try New flow, the account can end up with the stale Classic redirect state again.
The New Expensify decision is driven from nvp_tryNewDot.classicRedirect.dismissed: true means use Classic, false means use New Expensify.
A stale late SwitchToOldDot write can therefore put the account back into the Classic branch right as the user is trying to return to New Expensify.
What changes do you think we should make in order to solve the problem?
Make switchToOldDot return the API.write promise, then wait for that promise before opening Classic. This keeps the New-to-Classic state write ordered before the user can click Try New Expensify from Classic.
In ExitSurvey.ts, callers cannot wait for the SwitchToOldDot write because the promise is not returned.
The only code that needs to change in this function is the API.write call.
In DynamicExitSurveyConfirmPage.tsx, the button currently opens Classic immediately after starting the write.
Keep the same action, but move the dismiss/open logic into finally so the user still reaches Classic if the request fails.
In TroubleshootPage.tsx, the recent-survey shortcut has the same race because it starts switchToOldDot('') and opens Classic immediately.
Keep that shortcut, but wait for the returned promise before opening Classic.
This keeps the same user-facing flow, but guarantees that the New-to-Classic state write is no longer racing against the Classic-to-New state write triggered by Try New Expensify. Add focused tests for both callers: mock switchToOldDot with a deferred promise, trigger the Classic navigation action, assert that openOldDotLink is not called before the promise settles, then resolve the promise and assert that openOldDotLink(CONST.OLDDOT_URLS.INBOX, true) is called.
When the user is already authenticated in NewDot and OldDot's "Try New Expensify" link redirects the browser to https://staging.new.expensify.com/transition?email=...&shortLivedAuthToken=... (no exitTo parameter, because the link is meant to drop the user back on the NewDot home), three things converge to leave the page on a permanent FullScreenLoadingIndicator:
The /transition URL is loaded as a fresh full-page load on web. The session in localStorage is still valid, so AppNavigator in src/libs/Navigation/AppNavigator/AppNavigator.tsx:12-27 mounts AuthScreens, which routes SCREENS.TRANSITION_BETWEEN_APPS to LogOutPreviousUserPage (src/libs/Navigation/AppNavigator/AuthScreens.tsx:200, src/pages/LogOutPreviousUserPage.tsx:24).
The first useEffect (LogOutPreviousUserPage.tsx:31-64) falls through to the bottom branch and calls signInWithShortLivedAuthToken(shortLivedAuthToken) (src/libs/actions/Session/index.ts:815-819), whose getShortLivedLoginParams (Session/index.ts:154-219) flips account.isLoading to true optimistically and back to false in finallyData.
The second useEffect (LogOutPreviousUserPage.tsx:66-84) is the only path that can leave this screen. After isAccountLoading flips true → false it runs the navigation block at lines 75-81:
Navigation.goBack();
if (exitTo) {
Navigation.navigate(exitTo as Route);
}
Because the OldDot "Try New Expensify" link does not include exitTo, only the bare Navigation.goBack() executes. On this fresh load /transition is the only entry on the AuthScreens stack, so navigationRef.current.canGoBack() returns false and Navigation.goBack (src/libs/Navigation/Navigation.ts:496-515) just logs '[Navigation] Unable to go back' and returns. No navigation happens, the spinner stays.
The redundant safety net App.setUpPoliciesAndNavigate (src/libs/actions/App.ts:768-820), called from AuthScreensInitHandler.tsx:136, also bails out at line 780 (!currentUrl?.includes('exitTo')), so nothing else moves the user off /transition.
Note that the supportal branch in the same file (LogOutPreviousUserPage.tsx:43-51) was already hardened against this exact pattern by commit 48067694118 (Navigate to home instead of inbox), which appended Navigation.navigate(ROUTES.HOME) after Navigation.goBack(). The non-supportal branch in the second useEffect was never given the same treatment, which is why this regression surfaces only in the standard "Try New Expensify" flow.
What changes do you think we should make in order to solve the problem?
A single edit in src/pages/LogOutPreviousUserPage.tsx, inside the second useEffect's navigation block at lines 75-81:
Replace the conditional if (exitTo) { Navigation.navigate(exitTo as Route); } with an unconditional navigation to exitTo when present and to ROUTES.HOME otherwise. In other words, always navigate to some route after the goBack, defaulting to home when the OldDot link omitted exitTo. This mirrors the already-deployed supportal-branch pattern at lines 44-49 (signInWithSupportAuthToken → goBack → navigate(ROUTES.HOME)).
This makes the screen self-clearing in every case: when there is a previous route in history, goBack removes /transition; when there isn't, the explicit navigate(ROUTES.HOME) guarantees the user lands on the home screen rather than on a perpetual spinner. No edits to Navigation.ts, AuthScreensInitHandler.tsx, or setUpPoliciesAndNavigate are required, keeping the blast radius confined to the one file that owns the transition UI.
ROUTES.HOME is already imported at line 14 of the file, so no new import is needed.
What alternative solutions did you explore?
Adding 'exitTo' to OldDot's "Try New Expensify" URL builder. Out of repository — OldDot lives elsewhere — and it would still leave NewDot vulnerable to any other caller that constructs a /transition URL without exitTo. Fixing the consumer side (NewDot) is strictly more defensive.
Hardening Navigation.goBack itself to fall back to ROUTES.HOME when canGoBack() is false. Rejected — this would change the silent no-op contract that many other call sites rely on (e.g. dismissing modals where the desired behaviour is "do nothing if we're already at the root"), with a much larger blast radius than the actual bug warrants.
Calling setUpPoliciesAndNavigate even without exitTo by removing the currentUrl?.includes('exitTo') early-return at App.ts:780. Rejected — that early-return exists so the function only runs in transition contexts; loosening it would risk re-running policy bootstrap on every authenticated mount and is far broader than this fix needs.
Adding the getLastShortAuthToken() re-entry guard from LogInWithShortLivedAuthTokenPage.tsx:29-31 to the auth-side page. Worthwhile cleanup, but does not by itself unblock the spinner: even with the guard the second useEffect would still hit the silent goBack after the API completes once. Recommend handling separately if desired, not as part of this fix.
⚠️@oqildev Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Please re-state the problem that we are trying to solve in this issue.
When an authenticated user in New Expensify navigates to Troubleshoot, switches to Classic Expensify, and then clicks "Try New Expensify" to return, Classic redirects back with a transition URL that lacks an email parameter (because the user is the same person). The isLoggingInAsNewUser function incorrectly interprets the absence of an email parameter as evidence of a new user logging in, triggering a sign-out flow. This causes the user to be stuck on a loading screen after re-authentication, as the function's faulty logic fires repeatedly and eventually exhausts the short-lived auth token.
What is the root cause of that problem?
The bug originates in src/libs/SessionUtils.ts in the isLoggingInAsNewUser function (lines 10–40). When Classic redirects to NewDot via /transition?shortLivedAuthToken=...&exitTo=... (with no email parameter), the function receives a transition URL with no email information. Both paramsEmail (extracted via URLSearchParams) and linkedEmail (extracted via regex fallback) resolve to null. The final return statement evaluates null !== sessionEmail → true (since sessionEmail holds the user's actual email), causing the function to incorrectly conclude that a new user is logging in. This invokes signOutAndRedirectToSignIn in LogOutPreviousUserPage, which triggers a blocking server-side LogOut call. After re-authentication via the short-lived token, the user returns to LogOutPreviousUserPage, which re-enters the same faulty condition (still no email in the URL), signs out again, and eventually gets stuck when getLastShortAuthToken() prevents further re-authentication.
The semantic invariant violated is this: absence of an email parameter should indicate a same-user continuation (Classic → NewDot transition), not a new-user login attempt. The working analog is the isLoggingInAsDelegate function (also in src/libs/SessionUtils.ts), which correctly returns false when the delegator email is absent—treating missing data as a legitimate scenario rather than evidence of a new user.
What changes do you think we should make in order to solve the problem?
File:src/libs/SessionUtils.ts Function:isLoggingInAsNewUser Exact edit: After line 37 (the linkedDelegatorEmail assignment), insert an early-return guard. If both linkedEmail and linkedDelegatorEmail are null, no email parameter exists in the URL at all, meaning this is a same-user continuation from Classic to NewDot—not a new-user login. Return false immediately. Without this guard, the final return statement evaluates null !== sessionEmail → true, incorrectly triggering the sign-out flow.
Blast radius: Isolated to isLoggingInAsNewUser. The function has two callers: AuthScreensInitHandler (which the fix corrects for Classic→NewDot transitions) and useOnboardingFlowRouter (unaffected—real new-user onboarding URLs always carry an email parameter, so the null-guard is never reached).
What alternative solutions did you explore?
Location:src/libs/Navigation/AppNavigator/AuthScreensInitHandler.tsx Rejection reason: Adding a URL-shape check in AuthScreensInitHandler to skip the isLoggingInAsNewUser call would mask the semantic bug rather than fix it. The function has a contract violation (absent email = unknown user instead of same user) that affects any caller passing a no-email URL; the fix belongs in the function itself, not in the caller.
Location:src/libs/SessionUtils.ts (URLSearchParams line) Rejection reason: Changing new URLSearchParams(transitionURL) to new URLSearchParams(new URL(transitionURL).search) fixes the key-mangling side-effect but not the root cause. The Classic transition URL has no email parameter at all, so even with correct query-string parsing, paramsEmail would be null and the final return would still evaluate null !== sessionEmail → true.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
MelvinBot commentedon May 4, 2026
Proposal
What is the root cause of that problem?
When a user switches to Expensify Classic from the Troubleshoot page and then clicks "Try New Expensify" in Classic, Classic redirects back to NewDot via a
/transition?shortLivedAuthToken=xxx&exitTo=...URL. The user still has a valid session stored in IndexedDB from their previous NewDot session, so the app loads as authenticated and rendersLogOutPreviousUserPage.The bug is in
isLoggingInAsNewUser: it receives the full transition URL (e.g.https://staging.new.expensify.com/transition?shortLivedAuthToken=xxx) and passes it directly tonew URLSearchParams(). SinceURLSearchParamsexpects only a query string — not a full URL — the first parameter key is mangled (becomeshttps://staging.new.expensify.com/transition?shortLivedAuthTokeninstead ofshortLivedAuthToken). More importantly, the transition URL from Classic does not contain anemailparameter, so bothparams.get('email')and the regex fallback returnnull. The function then evaluatesnull !== sessionEmail→true, incorrectly concluding the user is "logging in as a new user".This triggers
signOutAndRedirectToSignIn, which calls the server-sideLogOutAPI viamakeRequestWithSideEffectsand waits for it to resolve before callingredirectToSignIn. During this wait, the user seesFullScreenLoadingIndicator. After sign-out completes, the user lands onLogInWithShortLivedAuthTokenPage, re-authenticates with the token, returns toLogOutPreviousUserPage, hits the sameisLoggingInAsNewUser→truecondition, and signs out again. The second time through,getLastShortAuthToken()prevents re-authentication, and the user either gets stuck on a loading indicator or lands onSessionExpiredPage— neither of which is the expected behavior (the app should just load normally since it's the same user).What changes do you think we should make in order to solve the problem?
In
LogOutPreviousUserPage, theisLoggingInAsNewUsercheck should be skipped when the transition URL has noemailparameter at all. The absence of anemailparameter means Classic didn't specify which user is transitioning — it simply means "continue as the current user." The function should only trigger a sign-out when a different email is explicitly present in the URL.The fix should be in
isLoggingInAsNewUser: if neitherparamsEmailnorlinkedEmail(from the regex fallback) is found in the URL, returnfalseearly — no email means no evidence of a different user.What alternative solutions did you explore? (Optional)
Fix
URLSearchParamsparsing: Extract just the query string before passing toURLSearchParams(e.g.,new URLSearchParams(new URL(transitionURL).search)). This would fix the parsing issue but wouldn't address the core problem that the transition URL lacks anemailparam entirely.Have Classic include the
emailparam: Modify the OldDot "Try New Expensify" redirect to include the user's email in the URL. This would makeisLoggingInAsNewUserwork correctly but requires a Classic-side change and doesn't fix the NewDot-side defensive gap.Supporting evidence
Key code path:
TroubleshootPage.tsx:137-139— triggersswitchToOldDot+openOldDotLinkto navigate to Classic in the same tabLogOutPreviousUserPage.tsx:31-41— first effect checksisLoggingInAsNewUserand callssignOutAndRedirectToSignInwhen trueSessionUtils.ts:10-40—isLoggingInAsNewUserreturnstruewhen no email is found in URL (becausenull !== sessionEmail)Session/index.ts:233-252—signOutusesmakeRequestWithSideEffects(blocking API call) which can hangLogInWithShortLivedAuthTokenPage.tsx:29—getLastShortAuthToken()check prevents re-authentication on second pass, leading toSessionExpiredPagePossibly related issue: #88243 — similar race condition with
NVP_TRY_NEW_DOTandSESSIONcallback timing on mobile HybridAppNext Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.melvin-bot commentedon May 4, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ahmedGaber93 (
External)[-]Switch flow - Page keeps on loading when click on Try New Expensify[/-][+][$250] Switch flow - Page keeps on loading when click on Try New Expensify[/+]melvin-bot commentedon May 4, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022051400482073037071
abbasifaizan70 commentedon May 4, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After a user signs in to
staging.new.expensify.com, goes to Account > Troubleshoot > Switch to Expensify Classic, and then clicks Try New Expensify from Expensify Classic, New Expensify should open normally. Instead, the New Expensify page stays on the loading screen and never finishes switching back into the New Expensify experience.What is the root cause of that problem?
The handoff to Classic starts from the troubleshoot page.
For the web flow, the menu item either routes the user through the exit survey or, when the survey was completed recently, opens Classic immediately after starting
switchToOldDot.App/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
Lines 136 to 149 in 9e1636e
The final exit-survey confirmation is the normal path that flips the account back to Classic.
It has the same ordering problem: it calls
switchToOldDot(exitSurveyResponse), dismisses the modal, and opens Classic in the same tab immediately afterward.App/src/pages/settings/ExitSurvey/DynamicExitSurveyConfirmPage.tsx
Lines 89 to 93 in 9e1636e
switchToOldDotstarts theSwitchToOldDotwrite request but does not return or await it.So both callers can navigate away from New Expensify before the write that sets the account back to Classic has finished.
App/src/libs/actions/ExitSurvey.ts
Lines 15 to 35 in 9e1636e
That creates a race with the Try New Expensify button in Classic.
If the delayed
SwitchToOldDotwrite completes after Classic starts the Try New flow, the account can end up with the stale Classic redirect state again.The New Expensify decision is driven from
nvp_tryNewDot.classicRedirect.dismissed:truemeans use Classic,falsemeans use New Expensify.A stale late
SwitchToOldDotwrite can therefore put the account back into the Classic branch right as the user is trying to return to New Expensify.App/src/libs/TryNewDotUtils.ts
Lines 38 to 48 in 9e1636e
What changes do you think we should make in order to solve the problem?
Make
switchToOldDotreturn theAPI.writepromise, then wait for that promise before opening Classic. This keeps the New-to-Classic state write ordered before the user can click Try New Expensify from Classic.In
ExitSurvey.ts, callers cannot wait for theSwitchToOldDotwrite because the promise is not returned.The only code that needs to change in this function is the
API.writecall.App/src/libs/actions/ExitSurvey.ts
Lines 29 to 35 in 9e1636e
In
DynamicExitSurveyConfirmPage.tsx, the button currently opens Classic immediately after starting the write.Keep the same action, but move the dismiss/open logic into
finallyso the user still reaches Classic if the request fails.App/src/pages/settings/ExitSurvey/DynamicExitSurveyConfirmPage.tsx
Lines 89 to 93 in 9e1636e
In
TroubleshootPage.tsx, the recent-survey shortcut has the same race because it startsswitchToOldDot('')and opens Classic immediately.Keep that shortcut, but wait for the returned promise before opening Classic.
App/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
Lines 136 to 140 in 9e1636e
This keeps the same user-facing flow, but guarantees that the New-to-Classic state write is no longer racing against the Classic-to-New state write triggered by Try New Expensify. Add focused tests for both callers: mock
switchToOldDotwith a deferred promise, trigger the Classic navigation action, assert thatopenOldDotLinkis not called before the promise settles, then resolve the promise and assert thatopenOldDotLink(CONST.OLDDOT_URLS.INBOX, true)is called.Abdulloh0109 commentedon May 4, 2026
Proposal
What is the root cause of that problem?
When the user is already authenticated in NewDot and OldDot's "Try New Expensify" link redirects the browser to
https://staging.new.expensify.com/transition?email=...&shortLivedAuthToken=...(noexitToparameter, because the link is meant to drop the user back on the NewDot home), three things converge to leave the page on a permanentFullScreenLoadingIndicator:The
/transitionURL is loaded as a fresh full-page load on web. The session inlocalStorageis still valid, soAppNavigatorinsrc/libs/Navigation/AppNavigator/AppNavigator.tsx:12-27mountsAuthScreens, which routesSCREENS.TRANSITION_BETWEEN_APPStoLogOutPreviousUserPage(src/libs/Navigation/AppNavigator/AuthScreens.tsx:200,src/pages/LogOutPreviousUserPage.tsx:24).The first
useEffect(LogOutPreviousUserPage.tsx:31-64) falls through to the bottom branch and callssignInWithShortLivedAuthToken(shortLivedAuthToken)(src/libs/actions/Session/index.ts:815-819), whosegetShortLivedLoginParams(Session/index.ts:154-219) flipsaccount.isLoadingtotrueoptimistically and back tofalseinfinallyData.The second
useEffect(LogOutPreviousUserPage.tsx:66-84) is the only path that can leave this screen. AfterisAccountLoadingflipstrue → falseit runs the navigation block at lines 75-81:Navigation.goBack();
if (exitTo) {
Navigation.navigate(exitTo as Route);
}
Because the OldDot "Try New Expensify" link does not include
exitTo, only the bareNavigation.goBack()executes. On this fresh load/transitionis the only entry on the AuthScreens stack, sonavigationRef.current.canGoBack()returnsfalseandNavigation.goBack(src/libs/Navigation/Navigation.ts:496-515) just logs'[Navigation] Unable to go back'and returns. No navigation happens, the spinner stays.The redundant safety net
App.setUpPoliciesAndNavigate(src/libs/actions/App.ts:768-820), called fromAuthScreensInitHandler.tsx:136, also bails out at line 780 (!currentUrl?.includes('exitTo')), so nothing else moves the user off/transition.Note that the supportal branch in the same file (
LogOutPreviousUserPage.tsx:43-51) was already hardened against this exact pattern by commit48067694118(Navigate to home instead of inbox), which appendedNavigation.navigate(ROUTES.HOME)afterNavigation.goBack(). The non-supportal branch in the seconduseEffectwas never given the same treatment, which is why this regression surfaces only in the standard "Try New Expensify" flow.What changes do you think we should make in order to solve the problem?
A single edit in
src/pages/LogOutPreviousUserPage.tsx, inside the seconduseEffect's navigation block at lines 75-81:if (exitTo) { Navigation.navigate(exitTo as Route); }with an unconditional navigation toexitTowhen present and toROUTES.HOMEotherwise. In other words, always navigate to some route after thegoBack, defaulting to home when the OldDot link omittedexitTo. This mirrors the already-deployed supportal-branch pattern at lines 44-49 (signInWithSupportAuthToken→goBack→navigate(ROUTES.HOME)).This makes the screen self-clearing in every case: when there is a previous route in history,
goBackremoves/transition; when there isn't, the explicitnavigate(ROUTES.HOME)guarantees the user lands on the home screen rather than on a perpetual spinner. No edits toNavigation.ts,AuthScreensInitHandler.tsx, orsetUpPoliciesAndNavigateare required, keeping the blast radius confined to the one file that owns the transition UI.ROUTES.HOMEis already imported at line 14 of the file, so no new import is needed.What alternative solutions did you explore?
'exitTo'to OldDot's "Try New Expensify" URL builder. Out of repository — OldDot lives elsewhere — and it would still leave NewDot vulnerable to any other caller that constructs a/transitionURL withoutexitTo. Fixing the consumer side (NewDot) is strictly more defensive.Navigation.goBackitself to fall back toROUTES.HOMEwhencanGoBack()is false. Rejected — this would change the silent no-op contract that many other call sites rely on (e.g. dismissing modals where the desired behaviour is "do nothing if we're already at the root"), with a much larger blast radius than the actual bug warrants.setUpPoliciesAndNavigateeven withoutexitToby removing thecurrentUrl?.includes('exitTo')early-return atApp.ts:780. Rejected — that early-return exists so the function only runs in transition contexts; loosening it would risk re-running policy bootstrap on every authenticated mount and is far broader than this fix needs.getLastShortAuthToken()re-entry guard fromLogInWithShortLivedAuthTokenPage.tsx:29-31to the auth-side page. Worthwhile cleanup, but does not by itself unblock the spinner: even with the guard the seconduseEffectwould still hit the silentgoBackafter the API completes once. Recommend handling separately if desired, not as part of this fix.oqildev commentedon May 4, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
github-actions commentedon May 4, 2026
aswin-s commentedon May 4, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When an authenticated user in New Expensify navigates to Troubleshoot, switches to Classic Expensify, and then clicks "Try New Expensify" to return, Classic redirects back with a transition URL that lacks an
emailparameter (because the user is the same person). TheisLoggingInAsNewUserfunction incorrectly interprets the absence of an email parameter as evidence of a new user logging in, triggering a sign-out flow. This causes the user to be stuck on a loading screen after re-authentication, as the function's faulty logic fires repeatedly and eventually exhausts the short-lived auth token.What is the root cause of that problem?
The bug originates in
src/libs/SessionUtils.tsin theisLoggingInAsNewUserfunction (lines 10–40). When Classic redirects to NewDot via/transition?shortLivedAuthToken=...&exitTo=...(with noemailparameter), the function receives a transition URL with no email information. BothparamsEmail(extracted viaURLSearchParams) andlinkedEmail(extracted via regex fallback) resolve tonull. The final return statement evaluatesnull !== sessionEmail→true(sincesessionEmailholds the user's actual email), causing the function to incorrectly conclude that a new user is logging in. This invokessignOutAndRedirectToSignIninLogOutPreviousUserPage, which triggers a blocking server-side LogOut call. After re-authentication via the short-lived token, the user returns toLogOutPreviousUserPage, which re-enters the same faulty condition (still no email in the URL), signs out again, and eventually gets stuck whengetLastShortAuthToken()prevents further re-authentication.The semantic invariant violated is this: absence of an
emailparameter should indicate a same-user continuation (Classic → NewDot transition), not a new-user login attempt. The working analog is theisLoggingInAsDelegatefunction (also insrc/libs/SessionUtils.ts), which correctly returnsfalsewhen the delegator email is absent—treating missing data as a legitimate scenario rather than evidence of a new user.App/src/libs/SessionUtils.ts
Lines 10 to 40 in e4b605b
What changes do you think we should make in order to solve the problem?
File:
src/libs/SessionUtils.tsFunction:
isLoggingInAsNewUserExact edit: After line 37 (the
linkedDelegatorEmailassignment), insert an early-return guard. If bothlinkedEmailandlinkedDelegatorEmailarenull, no email parameter exists in the URL at all, meaning this is a same-user continuation from Classic to NewDot—not a new-user login. Returnfalseimmediately. Without this guard, the final return statement evaluatesnull !== sessionEmail→true, incorrectly triggering the sign-out flow.Blast radius: Isolated to
isLoggingInAsNewUser. The function has two callers:AuthScreensInitHandler(which the fix corrects for Classic→NewDot transitions) anduseOnboardingFlowRouter(unaffected—real new-user onboarding URLs always carry an email parameter, so the null-guard is never reached).What alternative solutions did you explore?
Location:
src/libs/Navigation/AppNavigator/AuthScreensInitHandler.tsxRejection reason: Adding a URL-shape check in
AuthScreensInitHandlerto skip theisLoggingInAsNewUsercall would mask the semantic bug rather than fix it. The function has a contract violation (absent email = unknown user instead of same user) that affects any caller passing a no-email URL; the fix belongs in the function itself, not in the caller.Location:
src/libs/SessionUtils.ts(URLSearchParams line)Rejection reason: Changing
new URLSearchParams(transitionURL)tonew URLSearchParams(new URL(transitionURL).search)fixes the key-mangling side-effect but not the root cause. The Classic transition URL has no email parameter at all, so even with correct query-string parsing,paramsEmailwould benulland the final return would still evaluatenull !== sessionEmail→true.36 remaining items
melvin-bot commentedon May 14, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon May 15, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon May 15, 2026
@situchan is payment due? How much? I'm seeing 'revert' above
situchan commentedon May 15, 2026
Standard $250. There's no regression.
It's wrongly reverted so immediately re-reverted again.
Here's slack thread for context.
mallenexpensify commentedon May 15, 2026
Payment Summary
Contributor: @gijoe0295 due $250 via NewDot
Contributor+: @situchan due $250 via NewDot
JmillsExpensify commentedon May 18, 2026
$250 approved for @gijoe0295
laurenreidexpensify commentedon May 23, 2026
$250 approved for @situchan