Skip to content

Commit 3705687

Browse files
Skip module-level reset on initial SESSION load in HybridApp
The SESSION Onyx callback unconditionally reset currentTryNewDot and isLoadingTryNewDot on every accountID change, including the initial undefined → accountID transition. On mobile, when NVP_TRY_NEW_DOT fires before SESSION, the reset blanks already-populated state and Onyx never re-fires the NVP callback, leaving the module permanently stuck in a loading state. This caused closeReactNativeApp to silently no-op via shouldBlockOldAppExit. Now the reset is skipped on the initial session load (undefined → accountID). Real account switches (accountID1 → accountID2) and sign-outs still trigger the reset as before. Co-authored-by: Abdelrahman Khattab <abzokhattab@users.noreply.github.com>
1 parent a7b0b95 commit 3705687

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/libs/actions/HybridApp/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ Onyx.connectWithoutView({
5959
return;
6060
}
6161

62+
const isInitialSessionLoad = currentSessionAccountID === undefined;
6263
currentSessionAccountID = nextSessionAccountID;
64+
65+
if (isInitialSessionLoad) {
66+
return;
67+
}
68+
6369
currentTryNewDot = undefined;
6470
hasReceivedTryNewDotUpdate = false;
6571
isLoadingTryNewDot = nextSessionAccountID !== undefined || isLoadingApp !== false;

tests/unit/HybridAppActionsTest.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,31 @@ describe('HybridApp actions', () => {
155155
expect(closeNativeAppSpy).toHaveBeenCalledWith({shouldSetNVP: true});
156156
});
157157

158+
it('allows shouldSetNVP exits when NVP_TRY_NEW_DOT arrives before SESSION on initial app start', async () => {
159+
await Onyx.set(ONYXKEYS.IS_LOADING_APP, false);
160+
await waitForBatchedUpdatesWithAct();
161+
162+
// Simulate mobile ordering: NVP fires before SESSION
163+
await Onyx.set(ONYXKEYS.NVP_TRY_NEW_DOT, {
164+
classicRedirect: {
165+
dismissed: false,
166+
},
167+
});
168+
await waitForBatchedUpdatesWithAct();
169+
170+
// SESSION fires after NVP — this is the initial undefined → accountID transition
171+
await Onyx.set(ONYXKEYS.SESSION, {
172+
accountID: 1,
173+
authToken: 'auth-token',
174+
});
175+
await waitForBatchedUpdatesWithAct();
176+
177+
// closeReactNativeApp should still work because the initial session load
178+
// must not blank the already-populated currentTryNewDot
179+
closeReactNativeApp({shouldSetNVP: true, isTrackingGPS: false});
180+
expect(closeNativeAppSpy).toHaveBeenCalledWith({shouldSetNVP: true});
181+
});
182+
158183
it('preserves shouldSetNVP exits when the auth token rotates for the same session', async () => {
159184
await Onyx.multiSet({
160185
[ONYXKEYS.IS_LOADING_APP]: false,

0 commit comments

Comments
 (0)