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
[$250] Login - Unable to login to app once logout & attempt to login back #84849
Create a new gmail account (Note: OR try to login with any existing account)
Go through the onbaording
Logout of app
Enter same email address & valid magic code
Expected Result:
User able to login back to app once he logout & attempt to login back
Actual Result:
Unable to login to app once logout & login back. After entering magic code, loading icon seen on Sign in button & revert to Sign in & user is not signed in
This is a HybridApp-specific deadlock in the post-logout re-login flow. On HybridApp native, AppNavigator.native.tsx:15-21 requires bothauthenticated AND hybridApp.readyToShowAuthScreens to show auth screens (standalone only needs authenticated).
The function signInToOldDotAndChooseExperience (src/libs/HybridApp.ts:75-124) is responsible for setting readyToShowAuthScreens = true after sign-in. It has a strict precondition at line 95 that requires account.requiresTwoFactorAuth and account.needsTwoFactorAuthSetup to not be undefined. However, during signInWithValidateCode (src/libs/actions/Session/index.ts:876), the optimistic data spreads DEFAULT_ACCOUNT_DATA ({errors: null, success: '', isLoading: false}) which does not include these 2FA fields — leaving them undefined.
Additionally, at line 115, readyToShowAuthScreens is only set when tryNewDot !== undefined. But NVP_TRY_NEW_DOT is cleared by Onyx.clear() during logout and is only repopulated by the OpenApp API call, which runs inside AuthScreens (AuthScreensInitHandler.tsx:149). This creates a chicken-and-egg problem: AuthScreens needs readyToShowAuthScreens, which needs tryNewDot, which only comes from OpenApp, which only runs when AuthScreens mounts.
The result: after sign-in completes (authToken is set, spinner stops), readyToShowAuthScreens remains false, so AppNavigator continues showing the sign-in page.
What changes do you think we should make in order to solve the problem?
The signInToOldDotAndChooseExperience function in src/libs/HybridApp.ts should handle the post-logout sign-in case where tryNewDot is undefined. When the user signs in via the NewDot sign-in page (useNewDotSignInPage === true) and all other preconditions are met, but tryNewDot is still undefined (because OpenApp hasn't been called yet), the function should set readyToShowAuthScreens = true to break the deadlock and allow AuthScreens to mount. Once AuthScreens mounts, OpenApp will fetch NVP_TRY_NEW_DOT and the app can then make the OldDot/NewDot routing decision.
The early-return at line 95 checking for account.requiresTwoFactorAuth === undefined should also be reviewed — after a magic code sign-in where no 2FA is involved, these fields may legitimately be undefined in the server response, and the function should not block on them in that case.
What alternative solutions did you explore? (Optional)
Include NVP_TRY_NEW_DOT in the SigninUser API response — this would populate tryNewDot immediately after sign-in, avoiding the deadlock. However, this requires a backend change.
Preserve NVP_TRY_NEW_DOT across logout by adding it to keysToPreserve in Onyx.clear() — simpler but may cause stale data issues if the user's OldDot/NewDot preference changed server-side.
Include 2FA fields in DEFAULT_ACCOUNT_DATA (e.g., requiresTwoFactorAuth: false, needsTwoFactorAuthSetup: false) — this would prevent the early return at line 95 during the optimistic update phase. This is a reasonable complementary fix.
User enters email + magic code → signInWithValidateCode fires
Optimistic: account reset to DEFAULT_ACCOUNT_DATA (no 2FA fields), autoAuthState=SIGNING_IN
signInToOldDotAndChooseExperience fires but returns early (SIGNING_IN + missing 2FA fields)
Server responds: authToken set, autoAuthState=JUST_SIGNED_IN, credentials populated
Function fires again but tryNewDot is still undefined (cleared during logout, only fetchable via OpenApp)
Line 115: tryNewDot === undefined → setReadyToShowAuthScreens(true) never called → deadlock
Additional risks found:
getHybridAppSettings() returns null on second call (HybridAppHandler.tsx:41-46)
signOutFromOldDot is called twice during logout (Session/index.ts:406 and SignInRedirect.ts:87)
isHybridAppSetupFinished (module-level var) is never reset on logout
Possibly related:#82618 — "OD transition - Unable to log in to the app after logging out from OD" appears to describe a similar HybridApp post-logout login failure.
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 [-]Login - Unable to login to app once logout & attempt to login back[/-][+][$250] Login - Unable to login to app once logout & attempt to login back[/+]on Apr 13, 2026
Please re-state the problem that we are trying to solve in this issue.
On HybridApp (iOS), after logging out and re-authenticating with the same (or a different) email + magic code, the sign-in spinner disappears but the user is returned to the sign-in page instead of the app. The session is valid — only navigation is broken.
What is the root cause of that problem?
This is the same chicken-and-egg deadlock identified in #82618 and confirmed by the code:
AppNavigator.native.tsx:20 gates auth screens behind authenticated && hybridApp?.readyToShowAuthScreens. readyToShowAuthScreens = true is called inside signInToOldDotAndChooseExperience (HybridApp.ts:120) — but only when tryNewDot !== undefined (line 115).
After logout, Onyx.clear(keysToPreserve) is called with the list from App.ts:123-147. ONYXKEYS.NVP_TRY_NEW_DOT is not in that list, so it is wiped. On re-login, tryNewDot === undefined, the if at line 115 is never entered, readyToShowAuthScreens stays false, and AuthScreens never mounts. Since AuthScreens is where openApp is called (AuthScreensInitHandler.tsx:149), the value is never repopulated — completing the deadlock.
What changes do you think we should make in order to solve the problem?
Add ONYXKEYS.NVP_TRY_NEW_DOT to KEYS_TO_PRESERVE in App.ts:123:
const KEYS_TO_PRESERVE: OnyxKey[] = [
ONYXKEYS.ACCOUNT,
ONYXKEYS.IS_CHECKING_PUBLIC_ROOM,
...
ONYXKEYS.HYBRID_APP,
+ ONYXKEYS.NVP_TRY_NEW_DOT, // Preserve across logout so HybridApp routing isn't deadlocked on re-login
ONYXKEYS.SHOULD_USE_STAGING_SERVER,
...
];
Why this works:ONYXKEYS.CREDENTIALS is already preserved (keeping autoGeneratedLogin/autoGeneratedPassword). After re-login, signInToOldDotAndChooseExperience passes the line-95 guard (credentials set + 2FA fields populated by server response) and now also passes the tryNewDot !== undefined guard at line 115, calling setReadyToShowAuthScreens(true) — breaking the deadlock.
Stale-data risk is bounded:openApp runs immediately after AuthScreens mounts and overwrites NVP_TRY_NEW_DOT with the authenticated user's fresh server value. The preserved stale value is only used for the routing decision in the brief window before openApp responds. For the common case (same user re-logging in) it is exactly correct. For a different account, it may briefly show the wrong experience, but openApp corrects it in the same session.
This is consistent with the existing pattern: ONYXKEYS.HYBRID_APP is already preserved in this list and then immediately reset by resetSignInFlow().
What alternative solutions did you explore? Why did you reject them?
Add a special case in signInToOldDotAndChooseExperience for tryNewDot === undefined: Valid, but adds a conditional branch to auth routing logic and requires knowing whether to stay in NewDot or OldDot before that preference is known. The one-line KEYS_TO_PRESERVE change is semantically cleaner — the preference was already known from the previous session.
Include requiresTwoFactorAuth: false in DEFAULT_ACCOUNT_DATA: Risky — the optimistic merge would temporarily set false for users who have 2FA enabled. The line-95 guard for 2FA fields is not the blocking issue: these fields are populated by the server's SignInUserWithLink response before tryNewDot becomes the gating factor.
Backend change to include NVP_TRY_NEW_DOT in the SignInUserWithLink response: Correct fix long-term, but requires a backend change and is out of scope for this frontend bug.
🟢 On production everything works as expected on iPhone 17 Pro Max - iOS 26.4, app version v9.3.37-10:
ScreenRecording_04-13-2026.18-03-18_1.MP4
🟡 However on local Dev / iPhone 17 Pro Max Simulator - iOS 26.2, app version v9.3.59-2, I'm also not able to reproduce the issue with blocked after inputting the magic code, but there's another issue on my side where I'm not able to logout, unless I close and reopen the app (then I'm logged out - land on sign-in page):
Given I'm not able to reproduce the issue, I'm also not able to verify whether any of the proposed solutions actually do something - this might need a retest from QA on latest versions and if still consistently reproducible: assign to another C+ that's able to actually reproduce and verify the solutions ✅
Activity
MelvinBot commentedon Apr 13, 2026
Proposal
What is the root cause of that problem?
This is a HybridApp-specific deadlock in the post-logout re-login flow. On HybridApp native,
AppNavigator.native.tsx:15-21requires bothauthenticatedANDhybridApp.readyToShowAuthScreensto show auth screens (standalone only needsauthenticated).The function
signInToOldDotAndChooseExperience(src/libs/HybridApp.ts:75-124) is responsible for settingreadyToShowAuthScreens = trueafter sign-in. It has a strict precondition at line 95 that requiresaccount.requiresTwoFactorAuthandaccount.needsTwoFactorAuthSetupto not beundefined. However, duringsignInWithValidateCode(src/libs/actions/Session/index.ts:876), the optimistic data spreadsDEFAULT_ACCOUNT_DATA({errors: null, success: '', isLoading: false}) which does not include these 2FA fields — leaving themundefined.Additionally, at line 115,
readyToShowAuthScreensis only set whentryNewDot !== undefined. ButNVP_TRY_NEW_DOTis cleared byOnyx.clear()during logout and is only repopulated by theOpenAppAPI call, which runs insideAuthScreens(AuthScreensInitHandler.tsx:149). This creates a chicken-and-egg problem: AuthScreens needsreadyToShowAuthScreens, which needstryNewDot, which only comes fromOpenApp, which only runs when AuthScreens mounts.The result: after sign-in completes (authToken is set, spinner stops),
readyToShowAuthScreensremainsfalse, soAppNavigatorcontinues showing the sign-in page.What changes do you think we should make in order to solve the problem?
The
signInToOldDotAndChooseExperiencefunction insrc/libs/HybridApp.tsshould handle the post-logout sign-in case wheretryNewDotisundefined. When the user signs in via the NewDot sign-in page (useNewDotSignInPage === true) and all other preconditions are met, buttryNewDotis stillundefined(becauseOpenApphasn't been called yet), the function should setreadyToShowAuthScreens = trueto break the deadlock and allowAuthScreensto mount. OnceAuthScreensmounts,OpenAppwill fetchNVP_TRY_NEW_DOTand the app can then make the OldDot/NewDot routing decision.The early-return at line 95 checking for
account.requiresTwoFactorAuth === undefinedshould also be reviewed — after a magic code sign-in where no 2FA is involved, these fields may legitimately beundefinedin the server response, and the function should not block on them in that case.What alternative solutions did you explore? (Optional)
NVP_TRY_NEW_DOTin theSigninUserAPI response — this would populatetryNewDotimmediately after sign-in, avoiding the deadlock. However, this requires a backend change.NVP_TRY_NEW_DOTacross logout by adding it tokeysToPreserveinOnyx.clear()— simpler but may cause stale data issues if the user's OldDot/NewDot preference changed server-side.DEFAULT_ACCOUNT_DATA(e.g.,requiresTwoFactorAuth: false, needsTwoFactorAuthSetup: false) — this would prevent the early return at line 95 during the optimistic update phase. This is a reasonable complementary fix.Investigation details
Key code locations:
src/libs/Navigation/AppNavigator/AppNavigator.native.tsx:15-21— HybridApp auth gatesrc/libs/HybridApp.ts:75-124—signInToOldDotAndChooseExperiencewith early-return conditionssrc/libs/actions/Session/index.ts:876— optimistic data insignInWithValidateCodesrc/CONST/index.ts:2221—DEFAULT_ACCOUNT_DATAdefinitionsrc/libs/actions/SignInRedirect.ts:84-88— logout clears Onyx then resets HybridApp statesrc/libs/Navigation/AppNavigator/AuthScreensInitHandler.tsx:149—OpenAppcall locationData flow during the bug:
Onyx.clear()removesHYBRID_APP,NVP_TRY_NEW_DOT,CREDENTIALS,ACCOUNTresetSignInFlow()setsreadyToShowAuthScreens=false,useNewDotSignInPage=truesignInWithValidateCodefiresaccountreset toDEFAULT_ACCOUNT_DATA(no 2FA fields),autoAuthState=SIGNING_INsignInToOldDotAndChooseExperiencefires but returns early (SIGNING_IN + missing 2FA fields)autoAuthState=JUST_SIGNED_IN, credentials populatedtryNewDotis stillundefined(cleared during logout, only fetchable viaOpenApp)tryNewDot === undefined→setReadyToShowAuthScreens(true)never called → deadlockAdditional risks found:
getHybridAppSettings()returns null on second call (HybridAppHandler.tsx:41-46)signOutFromOldDotis called twice during logout (Session/index.ts:406 and SignInRedirect.ts:87)isHybridAppSetupFinished(module-level var) is never reset on logoutPossibly related: #82618 — "OD transition - Unable to log in to the app after logging out from OD" appears to describe a similar HybridApp post-logout login failure.
Next 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 Apr 13, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ikevin127 (
External)[-]Login - Unable to login to app once logout & attempt to login back[/-][+][$250] Login - Unable to login to app once logout & attempt to login back[/+]melvin-bot commentedon Apr 13, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022043616406257032348
Ltbltbltbltb commentedon Apr 13, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On HybridApp (iOS), after logging out and re-authenticating with the same (or a different) email + magic code, the sign-in spinner disappears but the user is returned to the sign-in page instead of the app. The session is valid — only navigation is broken.
What is the root cause of that problem?
This is the same chicken-and-egg deadlock identified in #82618 and confirmed by the code:
AppNavigator.native.tsx:20gates auth screens behindauthenticated && hybridApp?.readyToShowAuthScreens.readyToShowAuthScreens = trueis called insidesignInToOldDotAndChooseExperience(HybridApp.ts:120) — but only whentryNewDot !== undefined(line 115).After logout,
Onyx.clear(keysToPreserve)is called with the list fromApp.ts:123-147.ONYXKEYS.NVP_TRY_NEW_DOTis not in that list, so it is wiped. On re-login,tryNewDot === undefined, theifat line 115 is never entered,readyToShowAuthScreensstaysfalse, andAuthScreensnever mounts. SinceAuthScreensis whereopenAppis called (AuthScreensInitHandler.tsx:149), the value is never repopulated — completing the deadlock.What changes do you think we should make in order to solve the problem?
Add
ONYXKEYS.NVP_TRY_NEW_DOTtoKEYS_TO_PRESERVEinApp.ts:123:const KEYS_TO_PRESERVE: OnyxKey[] = [ ONYXKEYS.ACCOUNT, ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, ... ONYXKEYS.HYBRID_APP, + ONYXKEYS.NVP_TRY_NEW_DOT, // Preserve across logout so HybridApp routing isn't deadlocked on re-login ONYXKEYS.SHOULD_USE_STAGING_SERVER, ... ];Why this works:
ONYXKEYS.CREDENTIALSis already preserved (keepingautoGeneratedLogin/autoGeneratedPassword). After re-login,signInToOldDotAndChooseExperiencepasses the line-95 guard (credentials set + 2FA fields populated by server response) and now also passes thetryNewDot !== undefinedguard at line 115, callingsetReadyToShowAuthScreens(true)— breaking the deadlock.Stale-data risk is bounded:
openAppruns immediately afterAuthScreensmounts and overwritesNVP_TRY_NEW_DOTwith the authenticated user's fresh server value. The preserved stale value is only used for the routing decision in the brief window beforeopenAppresponds. For the common case (same user re-logging in) it is exactly correct. For a different account, it may briefly show the wrong experience, butopenAppcorrects it in the same session.This is consistent with the existing pattern:
ONYXKEYS.HYBRID_APPis already preserved in this list and then immediately reset byresetSignInFlow().What alternative solutions did you explore? Why did you reject them?
Add a special case in
signInToOldDotAndChooseExperiencefortryNewDot === undefined: Valid, but adds a conditional branch to auth routing logic and requires knowing whether to stay in NewDot or OldDot before that preference is known. The one-lineKEYS_TO_PRESERVEchange is semantically cleaner — the preference was already known from the previous session.Include
requiresTwoFactorAuth: falseinDEFAULT_ACCOUNT_DATA: Risky — the optimistic merge would temporarily setfalsefor users who have 2FA enabled. The line-95 guard for 2FA fields is not the blocking issue: these fields are populated by the server'sSignInUserWithLinkresponse beforetryNewDotbecomes the gating factor.Backend change to include
NVP_TRY_NEW_DOTin theSignInUserWithLinkresponse: Correct fix long-term, but requires a backend change and is out of scope for this frontend bug.ikevin127 commentedon Apr 14, 2026
🟢 On production everything works as expected on iPhone 17 Pro Max - iOS 26.4, app version v9.3.37-10:
ScreenRecording_04-13-2026.18-03-18_1.MP4
🟡 However on local Dev / iPhone 17 Pro Max Simulator - iOS 26.2, app version v9.3.59-2, I'm also not able to reproduce the issue with blocked after inputting the magic code, but there's another issue on my side where I'm not able to logout, unless I close and reopen the app (then I'm logged out - land on sign-in page):
Simulator.Screen.Recording.-.iPhone.17.Pro.Max.-.2026-04-13.at.18.13.43.mov
Given I'm not able to reproduce the issue, I'm also not able to verify whether any of the proposed solutions actually do something - this might need a retest from QA on latest versions and if still consistently reproducible: assign to another C+ that's able to actually reproduce and verify the solutions ✅
🎀👀🎀 C+ reviewed
melvin-bot commentedon Apr 14, 2026
Triggered auto assignment to @grgia, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
grgia commentedon Apr 14, 2026
Cannot reproduce either, closing