Repository navigation
Make Destroy debug button force an observable sign out - #96322
Conversation
Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
I looked into the failing checks. There's nothing to fix with a code push — the only failing check is the PR Author Checklist ( Why it's failing: The checklist job reports "0 out of 38 checklist items" completed. That's the human PR Author Checklist in the description, plus the Everything else is green:
To turn the checklist green: complete the PR Author Checklist and fill in the |
|
@aimane-chnaif any updates here? |
|
@MelvinBot pull main |
…ignOut Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
🤖 Merged |
|
The only failing check is PR Author Checklist / checklist, and it's not a code failure — there's nothing to push a fix for. It's failing because the checklist boxes haven't been ticked:
This is a human-completed checklist — I don't tick author-checklist boxes on a person's behalf. The PR author/assignee needs to review and check each item in the PR description, after which this check will pass on the next re-run. Every other check is green (or pending/skipped). No code changes are needed. |
|
@MelvinBot add Tests/QA Steps |
|
Added Tests and QA Steps to the PR description, derived from the diff. Both walk through the observable sign-out path and a regression check on Invalidate:
Please review and adjust the steps as the human co-author before marking the PR ready for review. |
DetailsExplanation of ChangeThe "Destroy" row in the Troubleshoot test-tool menu ( This implements Option 2 from the approved analysis: make "Destroy" force an observable sign out for debugging (e.g. to reproduce auth/logout issues). It now:
With credentials gone and the token corrupted, the request gets a "Invalidate" (reauth test — session stays active by design) is unchanged. Fixed Issues$ #95592 Tests
Offline testsN/A QA StepsSame as Tests
PR Author Checklist
@MelvinBot please set the PR body to the content in the details section above |
|
Updated the PR body to the content you provided. Two things I kept/adjusted so PR automation doesn't break:
Let me know if you'd like either of those changed. |
|
@MelvinBot mark as ready for review |
|
Marked this PR as ready for review. 🚀 |
|
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb SafariMacOS: Chrome / Safariweb.movweb2.mov |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9285aa187d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| Onyx.merge(ONYXKEYS.CREDENTIALS, {autoGeneratedLogin: '', autoGeneratedPassword: ''}).then(() => { | ||
| NetworkStore.setAuthToken(INVALID_TOKEN); | ||
| Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN}); | ||
| openApp(); |
There was a problem hiding this comment.
Clear stashed delegate credentials before forcing reauth
When Destroy is pressed while connected as a delegate, this only clears ONYXKEYS.CREDENTIALS; the reauth path detects delegate mode and reads ONYXKEYS.STASHED_CREDENTIALS instead (src/libs/Reauthentication.ts), which is populated when entering delegate mode. After the invalid-token openApp() gets a 407, reauth can succeed with those stashed credentials and restore the original account rather than hitting the missing-credentials redirect, so the button does not force a sign-out in delegate sessions. Clear the stashed credentials too or bypass reauth for this debug action.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — confirmed. In Reauthentication.ts the reauth path reads stashedCredentials when isConnectedAsDelegate is true, so clearing only CREDENTIALS would let a delegate session reauth successfully and restore the original account instead of signing out.
Fixed in 4b57a79 — invalidateCredentials now also clears STASHED_CREDENTIALS, waiting for both merges before firing the request:
App/src/libs/actions/Session/index.ts
Lines 1040 to 1053 in 4b57a79
| // reauth flow hits the missing-credentials guard, and the user is redirected to the sign-in screen. We wait for | ||
| // the credentials to be cleared in Onyx before firing the request so reauth reads the empty credentials. | ||
| Onyx.merge(ONYXKEYS.CREDENTIALS, {autoGeneratedLogin: '', autoGeneratedPassword: ''}).then(() => { | ||
| NetworkStore.setAuthToken(INVALID_TOKEN); |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
These two lines duplicate the entire body of the existing invalidateAuthToken() function defined just below (NetworkStore.setAuthToken(INVALID_TOKEN) followed by Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN})). Duplicating this token-invalidation logic means any future change (e.g. adding another session field to clear) has to be made in two places.
Call the existing helper instead of repeating its implementation:
Onyx.merge(ONYXKEYS.CREDENTIALS, {autoGeneratedLogin: '', autoGeneratedPassword: ''}).then(() => {
invalidateAuthToken();
openApp();
});Reviewed at: 9285aa1 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Done in 4b57a79 — replaced the duplicated token-invalidation lines with a call to the existing invalidateAuthToken() helper:
App/src/libs/actions/Session/index.ts
Lines 1049 to 1053 in 4b57a79
|
@MelvinBot address #96322 (comment), #96322 (comment) if applicable |
…estroy Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
@MonilBhavsar Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Both were applicable — addressed in 4b57a79.
Lint and TypeScript checks pass on the changed file. |
|
🚧 MonilBhavsar has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
Going to merge as it's for debugging purpose |
|
🚧 MonilBhavsar has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.4.43-0 🚀
|
|
🤖 I reviewed the changes in this PR and no help site changes are required, so I did not create a draft docs PR. Why: This PR only changes the behavior of the Destroy button in the developer Test Tool Menu (revealed via Settings > Troubleshoot) — it now forces an observable sign out by clearing device credentials, corrupting the local This test tool is not a user-facing feature and is not documented anywhere under @aimane-chnaif, please confirm you agree no help site update is needed here. If you believe a public article should cover this behavior, let me know and I'll draft one. |
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.4.43-1 🚀
Bundle Size Analysis (Sentry): |

Explanation of Change
The "Destroy" row in the Troubleshoot test-tool menu (
invalidateCredentials) previously only cleared the stored auto-generated device credentials. Because the currentauthTokenstayed valid and no request was fired, nothing observable happened — the user stayed signed in until some unrelated action later happened to trigger a reauth, so the button appeared to do nothing.This implements Option 2 from the approved analysis: make "Destroy" force an observable sign out for debugging (e.g. to reproduce auth/logout issues). It now:
authToken(INVALID_TOKEN), likeinvalidateAuthTokendoes.openApp()).With credentials gone and the token corrupted, the request gets a
407, the reauthentication flow hits the missing-credentials guard inReauthentication.ts, andredirectToSignInlands the tester on the login screen. The token corruption + request are chained after the credentialsOnyx.mergeresolves so the reauth flow reads the already-empty credentials. The comment above the button was updated to describe the new behavior."Invalidate" (reauth test — session stays active by design) is unchanged.
Fixed Issues
$ #95592
PROPOSAL: #95592 (comment)
Tests
Offline tests
N/A
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari