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
[$175] Web - App does not goes through the sign on page after press Invalidate #106782
Version Number: v9.5.37-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:https://github.com/Expensify/Expensify/issues/684139 Email or phone of affected tester (no customers): - Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Windows 11 - Chrome
Action Performed:
Precondition:
Needs an account on a domain with SAML required.
Sign in on web and open Reports.
Apply a filter, for example status:outstanding, and note the URL.
Open the test tools menu and press Invalidate auth token.
Expected Result:
Verify the app goes through the sign on page and comes back to the same Reports URL with the filter applied.
Actual Result:
App does not goes through the sign on page after press Invalidate
changed the title [-]Web - App does not goes through the sign on page after press Invalidate[/-][+][$175] Web - App does not goes through the sign on page after press Invalidate[/+]on Nov 12, 2026
A SAML-required account was unavailable, so the issue was not reproduced; testing covered only the supplied Gmail account on dev NewDot web. Code investigation suggests deferred token validation rather than a confirmed failure of SAML sign-on.
Step
Status
1. Sign in and open ReportsUsed the existing authenticated session, completed onboarding, and opened Spend → Reports. Sign-in was performed by CI.
✅
2. Apply status:outstanding and note URLApplied Outstanding through Filters and confirmed “Status: Outstanding.” The browser snapshot still reported the dev-server root URL, so a filter-bearing URL was not verified.
✅
3. Test tools → Invalidate auth tokenRuntime verification blocked: No SAML-required fixture; invalidation was not attempted. Preliminary root-cause hypothesis: The action replaces local tokens but does not issue a request or redirect (Session/index.ts:1171–1174). The replacement remains truthy, so the app still considers the user authenticated (useIsAuthenticated.tsx:6–9). Without a subsequent eligible request returning 407, reauthentication need not begin. Confidence: High in this code behavior, but low that it explains the reported run without its request/navigation trace.
⚠️
4. Go through sign-on and return to the same filtered Reports URLRuntime verification blocked: Neither the SAML round trip nor exact URL restoration was verified. Alternative checked: Ordinary required-SAML sessions should not silently refresh using device credentials: the SAML redirect branch runs first (Reauthentication.ts:223–265). Existing tests explicitly cover preserving the outstanding-filter path during forced SAML sign-out (SessionTest.ts:1483–1508); these were inspected, not executed. Recommended next check: Repeat with a confirmed SAML-required, non-support account and capture whether an authenticated request follows invalidation and returns 407. Compare click-only with invalidation followed by an authenticated request. If only the latter triggers sign-on, the immediate-sign-on expectation needs an explicit request trigger. If 407 occurs without sign-on, investigate the reauthentication guards before proposing a fix. No code change is yet verified as the solution.
Unlike invalidateCredentials() (which invokes openApp() after clearing credentials), invalidateAuthToken() does not fire any authenticated network request. Because token invalidation is deferred until the next network request, pressing "Invalidate" while viewing Reports does not generate a 407 response. Without a 407, the Reauthentication middleware is never executed, and accounts requiring SAML are not redirected to the SAML sign-in page.
What changes do you think we should make in order to solve the problem?
In src/libs/actions/Session/index.ts, trigger an immediate authenticated request (openApp()) within invalidateAuthToken() once the invalid token is set:
When openApp() executes with INVALID_TOKEN, the server returns a 407. For SAML-required accounts, Reauthentication.ts detects account?.isSAMLRequired and invokes redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true), sending the user through the SAML sign-on flow and returning to the current Reports URL with filters preserved.
What alternative solutions did you explore? (Optional)
Calling openApp() directly in TestToolMenu.tsx on the Invalidate button's onPress, but placing it in invalidateAuthToken() ensures any test trigger of invalidateAuthToken() immediately tests the reauthentication pipeline.
Please re-state the problem that we are trying to solve in this issue.
On a domain with SAML required, when a user opens Reports, applies a filter (e.g. status:outstanding), opens the Test Tools modal, and presses Invalidate (Authentication status -> Invalidate), nothing happens immediately — the app stays on the Reports page instead of exercising the SAML reauthentication flow (redirecting through the SAML sign-on page and returning to the filtered Reports URL).
What is the root cause of that problem?
invalidateAuthToken() corrupts the local token without firing an authenticated request to trigger the 407 -> reauthenticate() pipeline:
In src/libs/actions/Session/index.ts:1171-1174:
Because INVALID_TOKEN ('pizza') is a non-empty string, useIsAuthenticated() remains true. Reauthentication in NewDot is strictly request-driven: Reauthentication.ts:229-243 only runs when an API request is sent with the corrupted token and receives 407 NOT_AUTHENTICATED from the server. When the tester simply presses Invalidate while already on /search?q=status:outstanding (the QA step introduced by PR #100475), no network request is sent, so no 407 occurs and reauthenticate() is never invoked.
If openApp() is added inside invalidateAuthToken() without removing the redundant openApp() in invalidateCredentials(), pressing Destroy (invalidateCredentials()) will fire two concurrent OpenApp requests back-to-back!
What changes do you think we should make in order to solve the problem?
Update invalidateAuthToken() and invalidateCredentials() in src/libs/actions/Session/index.ts:1165-1174:
Have invalidateAuthToken() wait for the ONYXKEYS.SESSION merge to settle and then call openApp() so the reauthentication flow is immediately exercised:
For standard accounts (with valid CREDENTIALS in Onyx), openApp() gets a 407, Reauthentication.ts silently reauthenticates using autoGeneratedLogin/autoGeneratedPassword, mints a fresh token, and replays OpenApp while keeping the session active.
For SAML-required accounts (account?.isSAMLRequired), openApp() gets a 407, Reauthentication.ts:229-243 hits the SAML guard and calls redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true), preserving ONYXKEYS.LAST_VISITED_PATH (/search?q=status:outstanding) and redirecting through the SAML sign-on flow back to the filtered Reports URL.
In invalidateCredentials(), delegate the token invalidation + openApp() trigger to invalidateAuthToken() so openApp() is only called once:
Verify invalidateAuthToken() sets INVALID_TOKEN on ONYXKEYS.SESSION and dispatches WRITE_COMMANDS.OPEN_APP once.
Verify invalidateCredentials() clears ONYXKEYS.CREDENTIALS and ONYXKEYS.STASHED_CREDENTIALS, sets INVALID_TOKEN, and dispatches WRITE_COMMANDS.OPEN_APP exactly once (not twice).
What alternative solutions did you explore? (Optional)
Triggering a navigation or manual action after pressing Invalidate in QA steps: While performing another action that sends an API command after pressing Invalidate would eventually trigger a 407, firing openApp() inside invalidateAuthToken() (matching invalidateCredentials() from PR #96322) makes the Invalidate test tool immediately exercise the reauthentication pipeline on press without requiring the tester to find another action that triggers a network call.
Please re-state the problem that we are trying to solve in this issue.
On web, when an account on a SAML-required domain navigates to Reports, applies a filter (e.g. status:outstanding), opens the Test Tools menu, and clicks "Invalidate" under Authentication status, the app does not trigger the reauthentication pipeline to navigate through the SAML sign-in page and return to the filtered Reports URL.
invalidateAuthToken() only mutates in-memory and Onyx auth tokens to INVALID_TOKEN ('pizza'). It does not dispatch any authenticated network request.
In NewDot, the reauthentication flow is strictly request/response-driven: Reauthentication.ts:229-243 is only invoked when an in-flight API request is transmitted with an invalid token and the backend returns a 407 NOT_AUTHENTICATED error.
When the tester follows the QA steps introduced in PR [Payment due @huult] Keep the page across a forced SAML re-auth #100475 and simply clicks "Invalidate" while viewing /search?q=status:outstanding, no network request is dispatched. Because no request is sent, no 407 response is received, reauthenticate() never executes, and the SAML redirect (redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true)) is never triggered.
What changes do you think we should make in order to solve the problem?
In src/libs/actions/Session/index.ts:
Update invalidateAuthToken() to dispatch openApp() after Onyx.merge(ONYXKEYS.SESSION, ...) resolves:
In invalidateCredentials() right above line 1166, remove the redundant openApp() call so that invoking invalidateCredentials() triggers invalidateAuthToken() which dispatches openApp() exactly once, avoiding duplicate concurrent requests:
For standard accounts, Reauthentication.ts silently re-authenticates via stored credentials and stays on the active screen.
If offline, openApp() is queued by SequentialQueue and automatically executes once connectivity is restored, satisfying the offline QA requirements.
What alternative solutions did you explore? (Optional)
Calling openApp() directly inside TestToolMenu.tsx on the Invalidate button's onPress: Rejected because placing it directly in invalidateAuthToken() ensures all troubleshooting and test tool paths consistently trigger the reauthentication pipeline.
What automated tests can you add to prevent this from re-occurring?
In tests/actions/SessionTest.ts:
Add a unit test verifying that invalidateAuthToken() sets INVALID_TOKEN and dispatches WRITE_COMMANDS.OPEN_APP once.
Add a unit test verifying that invalidateCredentials() clears credentials and dispatches WRITE_COMMANDS.OPEN_APP exactly once.
invalidateAuthToken() in src/libs/actions/Session/index.ts:1171-1174 only calls NetworkStore.setAuthToken(INVALID_TOKEN) and merges the same value into ONYXKEYS.SESSION. It sends no request. In Reauthentication.ts the SAML-required branch (redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true)) runs only when a request comes back 407, so pressing Invalidate on a static Reports page never reaches it. The sibling action invalidateCredentials() (Session/index.ts:1165-1168) works because it calls openApp() right after invalidateAuthToken(). The "Invalidate" button in src/components/TestToolMenu.tsx has no such trigger.
What changes do you think we should make in order to solve the problem?
Fire the request from the button, not from the shared action. In TestToolMenu.tsx, change the Invalidate onPress to call invalidateAuthToken() and then openApp().
setAuthToken is synchronous, and Reauthentication.ts notes that requests read the NetworkStore token directly, so there is no need to wait for the Onyx.merge promise.
invalidateCredentials() stays untouched, so Destroy can never send two OpenApp requests.
The Invalidate with delay path (expireSessionWithDelay) keeps its deliberate no-request behaviour.
Test: in tests/ui/TestToolMenuTest.tsx, which already mocks @userActions/Session, mock openApp too. Press initialSettingsPage.troubleshoot.invalidate and assert invalidateAuthToken and openApp are each called once, in that order. Press ...destroy and assert openApp is not called by the menu (the action does it).
What alternative solutions did you explore? (Optional)
TassioSales, cocvn157 and tranvanminhnhat put openApp() inside invalidateAuthToken() (the latter two also edit invalidateCredentials()). That works, but it changes a shared action, needs the invalidateCredentials() refactor to avoid a double request, and adds an unneeded .then on the Onyx merge. Mine is a one-line change in the one caller that wants the request. MelvinBot's note that the request never fires is the same root cause.
Please re-state the problem that we are trying to solve in this issue.
On web with a SAML-required domain, after opening Reports and applying a filter (e.g. status:outstanding), pressing Invalidate (Authentication status -> Invalidate) in the Test Tools menu leaves the user on Reports instead of triggering reauthentication, redirecting through the SAML sign-in flow, and returning to the filtered Reports URL.
Test Tools calls invalidateAuthToken() directly in src/components/TestToolMenu.tsx#L168-L176. Because no API request is dispatched while sitting idle on Reports, no 407 NOT_AUTHENTICATED response is received.
SAML redirect only executes inside request-driven reauthenticate():
In src/libs/Reauthentication.ts#L229-L243, the account?.isSAMLRequired && !isSupportSession && !isSupportAuthTokenUsed branch only runs when an API request returns 407 and enters Reauthentication middleware (redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true)). By contrast, its sibling invalidateCredentials() explicitly calls openApp() right after invalidateAuthToken().
What changes do you think we should make in order to solve the problem?
Trigger openApp() once when Invalidate is pressed (without breaking expireSessionWithDelay() or causing invalidateCredentials() to dispatch a duplicate openApp()):
Option A (preferred — keep invalidateAuthToken() composable and avoid double-calling from invalidateCredentials()):
In src/libs/actions/Session/index.ts:
Parameterize invalidateAuthToken(shouldTriggerReauth = true) (or keep invalidateAuthToken local-only and fire openApp() at the TestToolMenu onPress site, passing false from invalidateCredentials() which already awaits credential clearing before calling openApp()):
And in invalidateCredentials(), pass invalidateAuthToken(false) before openApp() so credential clearing still completes before the single openApp() fires.
Wait for Onyx.merge(ONYXKEYS.SESSION, ...) to settle before openApp() when triggered via invalidateAuthToken(), so any Onyx subscribers reading SESSION see INVALID_TOKEN consistently while NetworkStore already has INVALID_TOKEN synchronously.
Leave expireSessionWithDelay() (src/libs/actions/Session/index.ts#L1179-L1185) untouched so the 15s delayed flow keeps its intended behavior.
What alternative solutions did we explore? (Optional)
Calling openApp() unconditionally inside invalidateAuthToken() without updating invalidateCredentials() (Session/index.ts#L1166-L1167), which would invoke openApp() synchronously in invalidateCredentials() and again in the .then() microtask; or firing openApp() only from TestToolMenu.tsx, which wouldn't cover callers invoking Session.invalidateAuthToken() directly.
Verification
Update tests/ui/TestToolMenuTest.tsx and/or tests/actions/SessionTest.ts to assert that triggering Invalidate invalidates SESSION.authToken and fires a single openApp() call, and that invalidateCredentials() still triggers openApp() only once after clearing credentials.
Setting NetworkStore.setAuthToken(INVALID_TOKEN) and updating ONYXKEYS.SESSION corrupts the token in memory and local storage, but sends no network request to the backend.
Reauthentication is only triggered when a network request receives a 407 response:
In src/libs/Network/MainQueue.ts and src/libs/actions/Reauthentication.ts, reauthentication logic (including the SAML redirection via redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true)) executes only when an outgoing authenticated API request fails with an HTTP 407 response. On a static view like Reports with no background polling or active user interactions, no network request is made, so the invalid token sits dormant and the 407 handler is never triggered.
Contrast this with invalidateCredentials() (lines 1156–1168) right above it:
invalidateCredentials() explicitly invokes openApp() to dispatch an authenticated request immediately after clearing credentials. In contrast, the "Invalidate" button in src/components/TestToolMenu.tsx (line 124) calls invalidateAuthToken() without firing any request.
What changes do you think we should make in order to solve the problem?
Trigger openApp() on Invalidate in src/components/TestToolMenu.tsx (lines 120–128):
Import openApp from @userActions/App in src/components/TestToolMenu.tsx and invoke it after invalidating the token:
{/* Instantly invalidates a user's local authToken. Useful for testing flows related to reauthentication. */}<TestToolRowtitle={translate('initialSettingsPage.troubleshoot.authenticationStatus')}><ButtonsentryLabel={CONST.SENTRY_LABEL.TEST_TOOL_MENU.INVALIDATE_AUTH_TOKEN}size={CONST.BUTTON_SIZE.SMALL}onPress={()=>{invalidateAuthToken();openApp();}}><Button.Text>{translate('initialSettingsPage.troubleshoot.invalidate')}</Button.Text></Button></TestToolRow>
When openApp() fires with the invalidated NetworkStore token, the backend returns a 407 response.
For SAML-required accounts (account?.isSAMLRequired), Reauthentication.ts detects the SAML domain requirement and calls redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true).
The current URL (e.g. /reports?status=outstanding) is preserved in ONYXKEYS.LAST_VISITED_PATH, the user transitions through the SAML sign-on flow, and upon successful authentication is routed back to the exact filtered Reports URL.
For standard accounts, the 407 is caught and automatically re-authenticated using stored credentials as expected.
Why triggering from TestToolMenu.tsx is superior to modifying invalidateAuthToken directly:
Keeps invalidateAuthToken() purely responsible for mutating the local token state, preserving separation of concerns.
Prevents invalidateCredentials() from dispatching duplicate openApp() requests.
Leaves expireSessionWithDelay() intact without altering its delayed expiration flow.
Automated Unit & UI Tests:
In tests/ui/TestToolMenuTest.tsx, add a test verifying that tapping the "Invalidate" button invokes both invalidateAuthToken and openApp in sequence.
Verify that tapping "Destroy" still calls invalidateCredentials without extra calls from the menu itself.
What alternative solutions did you explore? (Optional)
Putting openApp() inside invalidateAuthToken() directly:
Rejected because invalidateCredentials() already calls openApp() explicitly after awaiting the credential clearing promises (Promise.all([Onyx.merge(CREDENTIALS), Onyx.merge(STASHED_CREDENTIALS)])). Putting openApp() inside invalidateAuthToken() would cause invalidateCredentials() to fire two concurrent openApp() calls or would require modifying invalidateCredentials() with boolean flags. Calling openApp() directly from the button onPress in TestToolMenu.tsx is cleaner, safer, and completely avoids side effects.
Activity
melvin-bot commentedon Nov 12, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @cretadn22 (
External)[-]Web - App does not goes through the sign on page after press Invalidate[/-][+][$175] Web - App does not goes through the sign on page after press Invalidate[/+]melvin-bot commentedon Nov 12, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022120986943014784571
MelvinBot commentedon Nov 12, 2026
🤖 Web test steps verification results:⚠️ partial
A SAML-required account was unavailable, so the issue was not reproduced; testing covered only the supplied Gmail account on dev NewDot web. Code investigation suggests deferred token validation rather than a confirmed failure of SAML sign-on.
1. Sign in and open Reports
Used the existing authenticated session, completed onboarding, and opened Spend → Reports. Sign-in was performed by CI.2. Apply status:outstanding and note URL
Applied Outstanding through Filters and confirmed “Status: Outstanding.” The browser snapshot still reported the dev-server root URL, so a filter-bearing URL was not verified.3. Test tools → Invalidate auth token
Runtime verification blocked: No SAML-required fixture; invalidation was not attempted.Preliminary root-cause hypothesis: The action replaces local tokens but does not issue a request or redirect (Session/index.ts:1171–1174). The replacement remains truthy, so the app still considers the user authenticated (useIsAuthenticated.tsx:6–9). Without a subsequent eligible request returning 407, reauthentication need not begin.
Confidence: High in this code behavior, but low that it explains the reported run without its request/navigation trace.
4. Go through sign-on and return to the same filtered Reports URL
Runtime verification blocked: Neither the SAML round trip nor exact URL restoration was verified.Alternative checked: Ordinary required-SAML sessions should not silently refresh using device credentials: the SAML redirect branch runs first (Reauthentication.ts:223–265). Existing tests explicitly cover preserving the outstanding-filter path during forced SAML sign-out (SessionTest.ts:1483–1508); these were inspected, not executed.
Recommended next check: Repeat with a confirmed SAML-required, non-support account and capture whether an authenticated request follows invalidation and returns 407. Compare click-only with invalidation followed by an authenticated request. If only the latter triggers sign-on, the immediate-sign-on expectation needs an explicit request trigger. If 407 occurs without sign-on, investigate the reauthentication guards before proposing a fix. No code change is yet verified as the solution.
view run · view recording
TassioSales commentedon Nov 12, 2026
Proposal
What is the root cause of that problem?
In
src/libs/actions/Session/index.ts,invalidateAuthToken()exclusively updates local in-memory and Onyx state:Unlike
invalidateCredentials()(which invokesopenApp()after clearing credentials),invalidateAuthToken()does not fire any authenticated network request. Because token invalidation is deferred until the next network request, pressing "Invalidate" while viewing Reports does not generate a 407 response. Without a 407, theReauthenticationmiddleware is never executed, and accounts requiring SAML are not redirected to the SAML sign-in page.What changes do you think we should make in order to solve the problem?
In
src/libs/actions/Session/index.ts, trigger an immediate authenticated request (openApp()) withininvalidateAuthToken()once the invalid token is set:When
openApp()executes withINVALID_TOKEN, the server returns a 407. For SAML-required accounts,Reauthentication.tsdetectsaccount?.isSAMLRequiredand invokesredirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true), sending the user through the SAML sign-on flow and returning to the current Reports URL with filters preserved.What alternative solutions did you explore? (Optional)
Calling
openApp()directly inTestToolMenu.tsxon the Invalidate button'sonPress, but placing it ininvalidateAuthToken()ensures any test trigger ofinvalidateAuthToken()immediately tests the reauthentication pipeline.cocvn157 commentedon Nov 13, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On a domain with SAML required, when a user opens Reports, applies a filter (e.g.
status:outstanding), opens the Test Tools modal, and presses Invalidate (Authentication status -> Invalidate), nothing happens immediately — the app stays on the Reports page instead of exercising the SAML reauthentication flow (redirecting through the SAML sign-on page and returning to the filtered Reports URL).What is the root cause of that problem?
invalidateAuthToken()corrupts the local token without firing an authenticated request to trigger the407 -> reauthenticate()pipeline:In
src/libs/actions/Session/index.ts:1171-1174:Because
INVALID_TOKEN('pizza') is a non-empty string,useIsAuthenticated()remainstrue. Reauthentication in NewDot is strictly request-driven:Reauthentication.ts:229-243only runs when an API request is sent with the corrupted token and receives407 NOT_AUTHENTICATEDfrom the server. When the tester simply presses Invalidate while already on/search?q=status:outstanding(the QA step introduced by PR#100475), no network request is sent, so no407occurs andreauthenticate()is never invoked.Why
invalidateCredentials()insrc/libs/actions/Session/index.ts:1165-1168must also be updated ifinvalidateAuthToken()dispatchesopenApp():Look at
invalidateCredentials()right aboveinvalidateAuthToken()(added in PR#96322):If
openApp()is added insideinvalidateAuthToken()without removing the redundantopenApp()ininvalidateCredentials(), pressing Destroy (invalidateCredentials()) will fire two concurrentOpenApprequests back-to-back!What changes do you think we should make in order to solve the problem?
Update
invalidateAuthToken()andinvalidateCredentials()insrc/libs/actions/Session/index.ts:1165-1174:Have
invalidateAuthToken()wait for theONYXKEYS.SESSIONmerge to settle and then callopenApp()so the reauthentication flow is immediately exercised:CREDENTIALSin Onyx),openApp()gets a407,Reauthentication.tssilently reauthenticates usingautoGeneratedLogin/autoGeneratedPassword, mints a fresh token, and replaysOpenAppwhile keeping the session active.account?.isSAMLRequired),openApp()gets a407,Reauthentication.ts:229-243hits the SAML guard and callsredirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true), preservingONYXKEYS.LAST_VISITED_PATH(/search?q=status:outstanding) and redirecting through the SAML sign-on flow back to the filtered Reports URL.invalidateCredentials(), delegate the token invalidation +openApp()trigger toinvalidateAuthToken()soopenApp()is only called once:Add unit test coverage in
tests/actions/SessionTest.ts:invalidateAuthToken()setsINVALID_TOKENonONYXKEYS.SESSIONand dispatchesWRITE_COMMANDS.OPEN_APPonce.invalidateCredentials()clearsONYXKEYS.CREDENTIALSandONYXKEYS.STASHED_CREDENTIALS, setsINVALID_TOKEN, and dispatchesWRITE_COMMANDS.OPEN_APPexactly once (not twice).What alternative solutions did you explore? (Optional)
407, firingopenApp()insideinvalidateAuthToken()(matchinginvalidateCredentials()from PR#96322) makes the Invalidate test tool immediately exercise the reauthentication pipeline on press without requiring the tester to find another action that triggers a network call.tranvanminhnhat commentedon Nov 13, 2026
Contributor details
Your Expensify account email: tranvanminhnhat99@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01867c2936746cf5ca
Proposal
Please re-state the problem that we are trying to solve in this issue.
On web, when an account on a SAML-required domain navigates to Reports, applies a filter (e.g.
status:outstanding), opens the Test Tools menu, and clicks "Invalidate" under Authentication status, the app does not trigger the reauthentication pipeline to navigate through the SAML sign-in page and return to the filtered Reports URL.What is the root cause of that problem?
In
src/libs/actions/Session/index.ts:1171-1174:invalidateAuthToken()only mutates in-memory and Onyx auth tokens toINVALID_TOKEN('pizza'). It does not dispatch any authenticated network request.In NewDot, the reauthentication flow is strictly request/response-driven:
Reauthentication.ts:229-243is only invoked when an in-flight API request is transmitted with an invalid token and the backend returns a407 NOT_AUTHENTICATEDerror.When the tester follows the QA steps introduced in PR [Payment due @huult] Keep the page across a forced SAML re-auth #100475 and simply clicks "Invalidate" while viewing
/search?q=status:outstanding, no network request is dispatched. Because no request is sent, no407response is received,reauthenticate()never executes, and the SAML redirect (redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true)) is never triggered.What changes do you think we should make in order to solve the problem?
In
src/libs/actions/Session/index.ts:invalidateAuthToken()to dispatchopenApp()afterOnyx.merge(ONYXKEYS.SESSION, ...)resolves:invalidateCredentials()right above line 1166, remove the redundantopenApp()call so that invokinginvalidateCredentials()triggersinvalidateAuthToken()which dispatchesopenApp()exactly once, avoiding duplicate concurrent requests:When
invalidateAuthToken()triggersopenApp(), the server responds with407 NOT_AUTHENTICATED:account?.isSAMLRequired),Reauthentication.ts:229-243hits the SAML branch, triggeringredirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true).SignInRedirect.ts:111-120preservesONYXKEYS.LAST_VISITED_PATHand redirects through the SAML sign-in page back to the filtered Reports URL as expected by PR [Payment due @huult] Keep the page across a forced SAML re-auth #100475.Reauthentication.tssilently re-authenticates via stored credentials and stays on the active screen.openApp()is queued bySequentialQueueand automatically executes once connectivity is restored, satisfying the offline QA requirements.What alternative solutions did you explore? (Optional)
openApp()directly insideTestToolMenu.tsxon the Invalidate button'sonPress: Rejected because placing it directly ininvalidateAuthToken()ensures all troubleshooting and test tool paths consistently trigger the reauthentication pipeline.What automated tests can you add to prevent this from re-occurring?
In
tests/actions/SessionTest.ts:invalidateAuthToken()setsINVALID_TOKENand dispatchesWRITE_COMMANDS.OPEN_APPonce.invalidateCredentials()clears credentials and dispatchesWRITE_COMMANDS.OPEN_APPexactly once.melvin-bot commentedon Nov 13, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Stephen3453 commentedon Nov 13, 2026
Proposal
What is the root cause of that problem?
invalidateAuthToken()insrc/libs/actions/Session/index.ts:1171-1174only callsNetworkStore.setAuthToken(INVALID_TOKEN)and merges the same value intoONYXKEYS.SESSION. It sends no request. InReauthentication.tsthe SAML-required branch (redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true)) runs only when a request comes back 407, so pressing Invalidate on a static Reports page never reaches it. The sibling actioninvalidateCredentials()(Session/index.ts:1165-1168) works because it callsopenApp()right afterinvalidateAuthToken(). The "Invalidate" button insrc/components/TestToolMenu.tsxhas no such trigger.What changes do you think we should make in order to solve the problem?
Fire the request from the button, not from the shared action. In
TestToolMenu.tsx, change the InvalidateonPressto callinvalidateAuthToken()and thenopenApp().setAuthTokenis synchronous, andReauthentication.tsnotes that requests read the NetworkStore token directly, so there is no need to wait for theOnyx.mergepromise.invalidateCredentials()stays untouched, so Destroy can never send twoOpenApprequests.Invalidate with delaypath (expireSessionWithDelay) keeps its deliberate no-request behaviour.Test: in
tests/ui/TestToolMenuTest.tsx, which already mocks@userActions/Session, mockopenApptoo. PressinitialSettingsPage.troubleshoot.invalidateand assertinvalidateAuthTokenandopenAppare each called once, in that order. Press...destroyand assertopenAppis not called by the menu (the action does it).What alternative solutions did you explore? (Optional)
TassioSales, cocvn157 and tranvanminhnhat put
openApp()insideinvalidateAuthToken()(the latter two also editinvalidateCredentials()). That works, but it changes a shared action, needs theinvalidateCredentials()refactor to avoid a double request, and adds an unneeded.thenon the Onyx merge. Mine is a one-line change in the one caller that wants the request. MelvinBot's note that the request never fires is the same root cause.bradwue313 commentedon Nov 13, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On web with a SAML-required domain, after opening Reports and applying a filter (e.g.
status:outstanding), pressing Invalidate (Authentication status -> Invalidate) in the Test Tools menu leaves the user on Reports instead of triggering reauthentication, redirecting through the SAML sign-in flow, and returning to the filtered Reports URL.What is the root cause of that problem?
invalidateAuthToken()updates only local token state and fires no authenticated request:In
src/libs/actions/Session/index.ts#L1171-L1174:invalidateAuthToken()directly insrc/components/TestToolMenu.tsx#L168-L176. Because no API request is dispatched while sitting idle on Reports, no407 NOT_AUTHENTICATEDresponse is received.reauthenticate():In
src/libs/Reauthentication.ts#L229-L243, theaccount?.isSAMLRequired && !isSupportSession && !isSupportAuthTokenUsedbranch only runs when an API request returns407and entersReauthenticationmiddleware (redirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true)). By contrast, its siblinginvalidateCredentials()explicitly callsopenApp()right afterinvalidateAuthToken().What changes do you think we should make in order to solve the problem?
Trigger
openApp()once when Invalidate is pressed (without breakingexpireSessionWithDelay()or causinginvalidateCredentials()to dispatch a duplicateopenApp()):Option A (preferred — keep
invalidateAuthToken()composable and avoid double-calling frominvalidateCredentials()):In
src/libs/actions/Session/index.ts:invalidateAuthToken(shouldTriggerReauth = true)(or keepinvalidateAuthTokenlocal-only and fireopenApp()at the TestToolMenuonPresssite, passingfalsefrominvalidateCredentials()which already awaits credential clearing before callingopenApp()):invalidateCredentials(), passinvalidateAuthToken(false)beforeopenApp()so credential clearing still completes before the singleopenApp()fires.Onyx.merge(ONYXKEYS.SESSION, ...)to settle beforeopenApp()when triggered viainvalidateAuthToken(), so any Onyx subscribers readingSESSIONseeINVALID_TOKENconsistently whileNetworkStorealready hasINVALID_TOKENsynchronously.expireSessionWithDelay()(src/libs/actions/Session/index.ts#L1179-L1185) untouched so the 15s delayed flow keeps its intended behavior.What alternative solutions did we explore? (Optional)
Calling
openApp()unconditionally insideinvalidateAuthToken()without updatinginvalidateCredentials()(Session/index.ts#L1166-L1167), which would invokeopenApp()synchronously ininvalidateCredentials()and again in the.then()microtask; or firingopenApp()only fromTestToolMenu.tsx, which wouldn't cover callers invokingSession.invalidateAuthToken()directly.Verification
tests/ui/TestToolMenuTest.tsxand/ortests/actions/SessionTest.tsto assert that triggering Invalidate invalidatesSESSION.authTokenand fires a singleopenApp()call, and thatinvalidateCredentials()still triggersopenApp()only once after clearing credentials.Contributor details
Your Expensify account email: aurelis.work@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01678d37eeaca5d26f
melvin-bot commentedon Nov 13, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
kevinjosh10 commentedon Nov 14, 2026
Proposal
What is the root cause of that problem?
invalidateAuthToken()insrc/libs/actions/Session/index.ts(lines 1171–1174) only mutates local state without firing an authenticated request:NetworkStore.setAuthToken(INVALID_TOKEN)and updatingONYXKEYS.SESSIONcorrupts the token in memory and local storage, but sends no network request to the backend.In
src/libs/Network/MainQueue.tsandsrc/libs/actions/Reauthentication.ts, reauthentication logic (including the SAML redirection viaredirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true)) executes only when an outgoing authenticated API request fails with an HTTP 407 response. On a static view like Reports with no background polling or active user interactions, no network request is made, so the invalid token sits dormant and the 407 handler is never triggered.invalidateCredentials()(lines 1156–1168) right above it:invalidateCredentials()explicitly invokesopenApp()to dispatch an authenticated request immediately after clearing credentials. In contrast, the "Invalidate" button insrc/components/TestToolMenu.tsx(line 124) callsinvalidateAuthToken()without firing any request.What changes do you think we should make in order to solve the problem?
Trigger
openApp()on Invalidate insrc/components/TestToolMenu.tsx(lines 120–128):Import
openAppfrom@userActions/Appinsrc/components/TestToolMenu.tsxand invoke it after invalidating the token:openApp()fires with the invalidatedNetworkStoretoken, the backend returns a 407 response.account?.isSAMLRequired),Reauthentication.tsdetects the SAML domain requirement and callsredirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true)./reports?status=outstanding) is preserved inONYXKEYS.LAST_VISITED_PATH, the user transitions through the SAML sign-on flow, and upon successful authentication is routed back to the exact filtered Reports URL.Why triggering from
TestToolMenu.tsxis superior to modifyinginvalidateAuthTokendirectly:invalidateAuthToken()purely responsible for mutating the local token state, preserving separation of concerns.invalidateCredentials()from dispatching duplicateopenApp()requests.expireSessionWithDelay()intact without altering its delayed expiration flow.Automated Unit & UI Tests:
tests/ui/TestToolMenuTest.tsx, add a test verifying that tapping the "Invalidate" button invokes bothinvalidateAuthTokenandopenAppin sequence.invalidateCredentialswithout extra calls from the menu itself.What alternative solutions did you explore? (Optional)
openApp()insideinvalidateAuthToken()directly:Rejected because
invalidateCredentials()already callsopenApp()explicitly after awaiting the credential clearing promises (Promise.all([Onyx.merge(CREDENTIALS), Onyx.merge(STASHED_CREDENTIALS)])). PuttingopenApp()insideinvalidateAuthToken()would causeinvalidateCredentials()to fire two concurrentopenApp()calls or would require modifyinginvalidateCredentials()with boolean flags. CallingopenApp()directly from the buttononPressinTestToolMenu.tsxis cleaner, safer, and completely avoids side effects.Contributor details
Your Expensify account email: lkevinjosh10@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374