[$250] Web - App does not goes through the sign on page after press Invalidate
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
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
Workaround:
Unknown
Platforms:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome / Safari
Screenshots/Videos
https://github.com/user-attachments/assets/1c6a31f6-c9e1-4c96-92c7-ed8f160890b7
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022120986943014784571
- Upwork Job ID: 2120986943014784571
- Last Price Increase: 2026-11-28
Triggered auto assignment to Contributor-plus team member for initial proposal review - @cretadn22 (External)
Job added to Upwork: https://www.upwork.com/jobs/~022120986943014784571
🤖 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.
| 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. |
⚠️ |
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:
function invalidateAuthToken() {
NetworkStore.setAuthToken(INVALID_TOKEN);
Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN});
}
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:
function invalidateAuthToken() {
NetworkStore.setAuthToken(INVALID_TOKEN);
Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN}).then(() => {
openApp();
});
}
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.
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: Insrc/libs/actions/Session/index.ts:1171-1174:function invalidateAuthToken() { NetworkStore.setAuthToken(INVALID_TOKEN); Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN}); }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 atinvalidateCredentials()right aboveinvalidateAuthToken()(added in PR#96322):Promise.all([Onyx.merge(ONYXKEYS.CREDENTIALS, clearedCredentials), Onyx.merge(ONYXKEYS.STASHED_CREDENTIALS, clearedCredentials)]).then(() => { invalidateAuthToken(); openApp(); });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: HaveinvalidateAuthToken()wait for theONYXKEYS.SESSIONmerge to settle and then callopenApp()so the reauthentication flow is immediately exercised:- For standard accounts (with valid
CREDENTIALSin Onyx),openApp()gets a407,Reauthentication.tssilently reauthenticates usingautoGeneratedLogin/autoGeneratedPassword, mints a fresh token, and replaysOpenAppwhile keeping the session active. - For SAML-required accounts (
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. - In
invalidateCredentials(), delegate the token invalidation +openApp()trigger toinvalidateAuthToken()soopenApp()is only called once:
function invalidateCredentials() { const clearedCredentials = {autoGeneratedLogin: '', autoGeneratedPassword: ''}; Promise.all([Onyx.merge(ONYXKEYS.CREDENTIALS, clearedCredentials), Onyx.merge(ONYXKEYS.STASHED_CREDENTIALS, clearedCredentials)]).then(() => { invalidateAuthToken(); }); } function invalidateAuthToken() { NetworkStore.setAuthToken(INVALID_TOKEN); Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN}).then(() => { openApp(); }); } - For standard accounts (with valid
-
Add unit test coverage in
tests/actions/SessionTest.ts:- Verify
invalidateAuthToken()setsINVALID_TOKENonONYXKEYS.SESSIONand dispatchesWRITE_COMMANDS.OPEN_APPonce. - Verify
invalidateCredentials()clearsONYXKEYS.CREDENTIALSandONYXKEYS.STASHED_CREDENTIALS, setsINVALID_TOKEN, and dispatchesWRITE_COMMANDS.OPEN_APPexactly once (not twice).
- Verify
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, 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.
Contributor details Your Expensify account email: [email protected] 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:function invalidateAuthToken() { NetworkStore.setAuthToken(INVALID_TOKEN); Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN}); }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 #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:- Update
invalidateAuthToken()to dispatchopenApp()afterOnyx.merge(ONYXKEYS.SESSION, ...)resolves:function invalidateAuthToken() { NetworkStore.setAuthToken(INVALID_TOKEN); Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN}).then(() => { openApp(); }); } - In
invalidateCredentials()right above line 1166, remove the redundantopenApp()call so that invokinginvalidateCredentials()triggersinvalidateAuthToken()which dispatchesopenApp()exactly once, avoiding duplicate concurrent requests:function invalidateCredentials() { const clearedCredentials = {autoGeneratedLogin: '', autoGeneratedPassword: ''}; Promise.all([Onyx.merge(ONYXKEYS.CREDENTIALS, clearedCredentials), Onyx.merge(ONYXKEYS.STASHED_CREDENTIALS, clearedCredentials)]).then(() => { invalidateAuthToken(); }); }
- Update
-
When
invalidateAuthToken()triggersopenApp(), the server responds with407 NOT_AUTHENTICATED:- For SAML-required accounts (
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 #100475.- For standard accounts,
Reauthentication.tssilently re-authenticates via stored credentials and stays on the active screen. - If offline,
openApp()is queued bySequentialQueueand automatically executes once connectivity is restored, satisfying the offline QA requirements.
- For SAML-required accounts (
What alternative solutions did you explore? (Optional)
- Calling
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:
- Add a unit test verifying that
invalidateAuthToken()setsINVALID_TOKENand dispatchesWRITE_COMMANDS.OPEN_APPonce. - Add a unit test verifying that
invalidateCredentials()clears credentials and dispatchesWRITE_COMMANDS.OPEN_APPexactly once.
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
What is the root cause of that problem?
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().
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.- The
Invalidate with delaypath (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.
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: Insrc/libs/actions/Session/index.ts#L1171-L1174:
Test Tools callsfunction invalidateAuthToken() { NetworkStore.setAuthToken(INVALID_TOKEN); Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN}); }invalidateAuthToken()directly insrc/components/TestToolMenu.tsx#L168-L176. Because no API request is dispatched while sitting idle on Reports, no407 NOT_AUTHENTICATEDresponse is received.- SAML redirect only executes inside request-driven
reauthenticate(): Insrc/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 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 keepinvalidateAuthTokenlocal-only and fireopenApp()at the TestToolMenuonPresssite, passingfalsefrominvalidateCredentials()which already awaits credential clearing before callingopenApp()):
And infunction invalidateAuthToken(shouldTriggerReauth = true) { NetworkStore.setAuthToken(INVALID_TOKEN); Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN}).then(() => { if (shouldTriggerReauth) { openApp(); } }); }invalidateCredentials(), passinvalidateAuthToken(false)beforeopenApp()so credential clearing still completes before the singleopenApp()fires. - Wait for
Onyx.merge(ONYXKEYS.SESSION, ...)to settle beforeopenApp()when triggered viainvalidateAuthToken(), so any Onyx subscribers readingSESSIONseeINVALID_TOKENconsistently whileNetworkStorealready hasINVALID_TOKENsynchronously. - 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.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: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01678d37eeaca5d26f
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
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:
Settingfunction invalidateAuthToken() { NetworkStore.setAuthToken(INVALID_TOKEN); Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN}); }NetworkStore.setAuthToken(INVALID_TOKEN)and updatingONYXKEYS.SESSIONcorrupts 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.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. - Contrast this with
invalidateCredentials()(lines 1156–1168) right above it:Promise.all([Onyx.merge(ONYXKEYS.CREDENTIALS, clearedCredentials), Onyx.merge(ONYXKEYS.STASHED_CREDENTIALS, clearedCredentials)]).then(() => { invalidateAuthToken(); openApp(); });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): ImportopenAppfrom@userActions/Appinsrc/components/TestToolMenu.tsxand invoke it after invalidating the token:{/* Instantly invalidates a user's local authToken. Useful for testing flows related to reauthentication. */} <TestToolRow title={translate('initialSettingsPage.troubleshoot.authenticationStatus')}> <Button sentryLabel={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 invalidatedNetworkStoretoken, the backend returns a 407 response. - For SAML-required accounts (
account?.isSAMLRequired),Reauthentication.tsdetects the SAML domain requirement and callsredirectToSignIn(CONST.SIGN_OUT_REASON.SAML_REQUIRED, undefined, true). - The current URL (e.g.
/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. - For standard accounts, the 407 is caught and automatically re-authenticated using stored credentials as expected.
- When
-
Why triggering from
TestToolMenu.tsxis superior to modifyinginvalidateAuthTokendirectly:- Keeps
invalidateAuthToken()purely responsible for mutating the local token state, preserving separation of concerns. - Prevents
invalidateCredentials()from dispatching duplicateopenApp()requests. - Leaves
expireSessionWithDelay()intact without altering its delayed expiration flow.
- Keeps
-
Automated Unit & UI Tests:
- In
tests/ui/TestToolMenuTest.tsx, add a test verifying that tapping the "Invalidate" button invokes bothinvalidateAuthTokenandopenAppin sequence. - Verify that tapping "Destroy" still calls
invalidateCredentialswithout extra calls from the menu itself.
- In
What alternative solutions did you explore? (Optional)
- Putting
openApp()insideinvalidateAuthToken()directly: Rejected becauseinvalidateCredentials()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: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374
@cretadn22 Huh... This is 4 days overdue. Who can take care of this?
@allgandalf I saw you have worked heavily on SAML features. Could you help me get SAML set up on a test account so I can work on this issue?
@cretadn22 Melvin's analysis attributes the missing sign-on to no request following invalidateAuthToken(), but the video has one: after pressing Invalidate (~0:58) the tester reloads the page (~1:18), every load sends openApp()/reconnectApp() with the token taken from ONYXKEYS.SESSION, so by that reload at the latest a 407 has gone through reauthenticate(), where the SAML redirect is gated on account?.isSAMLRequired:
https://github.com/Expensify/App/blob/f8e95192946cf1efad04f4a11dc2363176c2951e/src/libs/Reauthentication.ts#L225-L238
redirectToSignIn() always clears the session, yet the app stays signed in on the filtered /search URL and keeps opening reports, so that branch was skipped for this account, and adding openApp() after Invalidate (the direction every proposal here takes) only sends one more request down the same path. What needs pinning down is why account.isSAMLRequired is not true in that session (the account data or the domain's SAML setting), not whether a request fires.
Happy to put up a full proposal for this if that's useful.
@allgandalf I saw you have worked heavily on SAML features. Could you help me get SAML set up on a test account so I can work on this issue?
You would need to have a private domain to test this
@cretadn22 Eep! 4 days overdue now. Issues have feelings too...
@MelvinBot can you make a proposal to fix this issue?
Proposal assessment — root cause not yet verified
Adding openApp() explains the immediate-click symptom, but it is not yet a verified fix for the full reported behavior.
What is the root cause of that problem?
Confirmed: Invalidate only replaces local tokens; it does not send a request to trigger reauthentication.
Unresolved: yusufdeveloper2903 reported that the recording also shows a reload. Normal authenticated startup invokes OpenApp or ReconnectApp, so “no request after clicking Invalidate” does not fully explain that sequence.
Remaining signed in also does not prove account.isSAMLRequired was false: we need to establish which token was transmitted, whether a 407 occurred, and which authentication branch ran.
Code evidence
- Session/index.ts:1227–1230: local-only invalidation.
- AuthScreensInitHandler.tsx:220–244: startup requests.
- Reauthentication.ts:211–260: required-SAML redirect, support-session exceptions, and device-credential authentication.
What changes do you think we should make?
I would not approve an implementation yet. The missing evidence is a reproduction with a confirmed SAML-required, non-support account, capturing:
- Whether invalidation and reload produce a
407. - The account’s
isSAMLRequiredvalue and support-session flags. - Whether device-credential authentication or a SAML round trip follows.
- Whether the original filtered URL is restored.
No such fixture or trace was available; I have not reproduced the SAML flow.
What alternative solutions did you explore?
Calling openApp() immediately after invalidation in the button handler is the smallest change for the click-only requirement. However, it cannot fix an incorrectly bypassed SAML branch. The reload behavior must be resolved before presenting that change as this issue’s solution.
@cretadn22 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
MelvinBot's assessment isn't correct. I tested with an account on a SAML-required domain. Pressing Invalidate does nothing by itself, but as soon as a request goes out (for me, when I closed the Test Tools modal), the app goes through SAML sign-on. So the SAML branch in reauthenticate() is not being skipped