Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/libs/actions/HybridApp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ Onyx.connectWithoutView({
return;
}

const isInitialSessionLoad = currentSessionAccountID === undefined;
currentSessionAccountID = nextSessionAccountID;

if (isInitialSessionLoad) {
return;
}

currentTryNewDot = undefined;
hasReceivedTryNewDotUpdate = false;
isLoadingTryNewDot = nextSessionAccountID !== undefined || isLoadingApp !== false;
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/HybridAppActionsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,31 @@ describe('HybridApp actions', () => {
expect(closeNativeAppSpy).toHaveBeenCalledWith({shouldSetNVP: true});
});

it('allows shouldSetNVP exits when NVP_TRY_NEW_DOT arrives before SESSION on initial app start', async () => {
await Onyx.set(ONYXKEYS.IS_LOADING_APP, false);
await waitForBatchedUpdatesWithAct();

// Simulate mobile ordering: NVP fires before SESSION
await Onyx.set(ONYXKEYS.NVP_TRY_NEW_DOT, {
classicRedirect: {
dismissed: false,
},
});
await waitForBatchedUpdatesWithAct();

// SESSION fires after NVP — this is the initial undefined → accountID transition
await Onyx.set(ONYXKEYS.SESSION, {
accountID: 1,
authToken: 'auth-token',
});
await waitForBatchedUpdatesWithAct();

// closeReactNativeApp should still work because the initial session load
// must not blank the already-populated currentTryNewDot
closeReactNativeApp({shouldSetNVP: true, isTrackingGPS: false});
expect(closeNativeAppSpy).toHaveBeenCalledWith({shouldSetNVP: true});
});

it('preserves shouldSetNVP exits when the auth token rotates for the same session', async () => {
await Onyx.multiSet({
[ONYXKEYS.IS_LOADING_APP]: false,
Expand Down
Loading