Skip to content

Make Destroy debug button force an observable sign out - #96322

Merged
MonilBhavsar merged 3 commits into
mainfrom
claude-destroyForcesSignOut
Jul 22, 2026
Merged

MonilBhavsar merged 3 commits into
mainfrom
claude-destroyForcesSignOut

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The "Destroy" row in the Troubleshoot test-tool menu (invalidateCredentials) previously only cleared the stored auto-generated device credentials. Because the current authToken stayed 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:

  1. Clears the stored credentials (as before).
  2. Corrupts the local authToken (INVALID_TOKEN), like invalidateAuthToken does.
  3. Fires an authenticated request (openApp()).

With credentials gone and the token corrupted, the request gets a 407, the reauthentication flow hits the missing-credentials guard in Reauthentication.ts, and redirectToSignIn lands the tester on the login screen. The token corruption + request are chained after the credentials Onyx.merge resolves 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

  1. Sign in.
  2. Open Settings > Troubleshoot to reveal the Test Tool Menu.
  3. Tap Destroy in the Device credentials row → verify you're signed out and land on the sign-in screen.
  4. Sign back in, tap Invalidate → verify the session stays active (reauth test, unchanged).
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as Tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@codecov

codecov Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

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.

Files with missing lines Coverage Δ
src/components/TestToolMenu.tsx 92.85% <ø> (ø)
src/libs/actions/Session/index.ts 42.50% <0.00%> (-0.27%) ⬇️
... and 14 files with indirect coverage changes

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I looked into the failing checks. There's nothing to fix with a code push — the only failing check is the PR Author Checklist (checklist), and that one is expected to fail here.

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 Tests/QA Steps sections that this PR intentionally leaves as // TODO: The human co-author must fill out.... I won't check those boxes or write test steps on your behalf — they need to reflect what you actually tested.

Everything else is green:

  • ✅ ESLint, typecheck, all 8 test jobs, Bun tests, Storybook, spellcheck, builds — all passing
  • ⏳ baseline-perf-tests / branch-perf-tests are still running (informational benchmarks, not blocking)

To turn the checklist green: complete the PR Author Checklist and fill in the Tests / QA Steps sections in the PR body, then re-run the check.

@MonilBhavsar

Copy link
Copy Markdown
Contributor

@aimane-chnaif any updates here?

@aimane-chnaif

Copy link
Copy Markdown
Contributor

@MelvinBot pull main

…ignOut

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Merged main into claude-destroyForcesSignOut and pushed. The merge was clean with no conflicts.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

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:

You completed 0 out of 38 checklist items with 38 unfinished items
❌ PR Author Checklist is not completely filled out. Please check every box to verify you've thought about the item.

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.

@aimane-chnaif

Copy link
Copy Markdown
Contributor

@MelvinBot add Tests/QA Steps

@MelvinBot

Copy link
Copy Markdown
Contributor Author

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:

  1. Sign in.
  2. Open Settings > Troubleshoot to reveal the Test Tool Menu.
  3. Tap Destroy in the Device credentials row → verify you're signed out and land on the sign-in screen.
  4. Sign back in, tap Invalidate → verify the session stays active (reauth test, unchanged).
  5. Verify no JS console errors.

Please review and adjust the steps as the human co-author before marking the PR ready for review.

@aimane-chnaif

aimane-chnaif commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor
Details

Explanation of Change

The "Destroy" row in the Troubleshoot test-tool menu (invalidateCredentials) previously only cleared the stored auto-generated device credentials. Because the current authToken stayed 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:

  1. Clears the stored credentials (as before).
  2. Corrupts the local authToken (INVALID_TOKEN), like invalidateAuthToken does.
  3. Fires an authenticated request (openApp()).

With credentials gone and the token corrupted, the request gets a 407, the reauthentication flow hits the missing-credentials guard in Reauthentication.ts, and redirectToSignIn lands the tester on the login screen. The token corruption + request are chained after the credentials Onyx.merge resolves 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

Tests

  1. Sign in.
  2. Open Settings > Troubleshoot to reveal the Test Tool Menu.
  3. Tap Destroy in the Device credentials row → verify you're signed out and land on the sign-in screen.
  4. Sign back in, tap Invalidate → verify the session stays active (reauth test, unchanged).
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as Tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

@MelvinBot please set the PR body to the content in the details section above

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Updated the PR body to the content you provided.

Two things I kept/adjusted so PR automation doesn't break:

  • Fixed Issues: your snippet had an empty issue link (.../issues/), so I filled in the actual linked issue (.../issues/95592) and kept the PROPOSAL: line — an empty link would fail the required issue-linking check.
  • Screenshots/Videos: preserved the existing (empty) platform sections since your snippet ended at the checklist.

Let me know if you'd like either of those changed.

@aimane-chnaif

Copy link
Copy Markdown
Contributor

@MelvinBot mark as ready for review

@MelvinBot
MelvinBot marked this pull request as ready for review July 22, 2026 17:10
@MelvinBot
MelvinBot requested a review from a team as a code owner July 22, 2026 17:10
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Marked this PR as ready for review. 🚀

@melvin-bot
melvin-bot Bot requested review from aimane-chnaif and removed request for a team July 22, 2026 17:10
@melvin-bot

melvin-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

@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]

@melvin-bot
melvin-bot Bot requested review from trjExpensify and removed request for a team July 22, 2026 17:10
@aimane-chnaif

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov
web2.mov

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/libs/actions/Session/index.ts Outdated
Comment on lines +1045 to +1048
Onyx.merge(ONYXKEYS.CREDENTIALS, {autoGeneratedLogin: '', autoGeneratedPassword: ''}).then(() => {
NetworkStore.setAuthToken(INVALID_TOKEN);
Onyx.merge(ONYXKEYS.SESSION, {authToken: INVALID_TOKEN, encryptedAuthToken: INVALID_TOKEN});
openApp();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

function invalidateCredentials() {
// Force an observable sign out for debugging: clear the stored device credentials so reauthentication can't
// succeed, then corrupt the local authToken and fire an authenticated request. The request gets a 407, the
// 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. While
// connected as a delegate, reauth reads STASHED_CREDENTIALS instead of CREDENTIALS, so we clear those too -
// otherwise reauth would succeed with the stashed credentials and restore the original account instead of
// signing out.
const clearedCredentials = {autoGeneratedLogin: '', autoGeneratedPassword: ''};
Promise.all([Onyx.merge(ONYXKEYS.CREDENTIALS, clearedCredentials), Onyx.merge(ONYXKEYS.STASHED_CREDENTIALS, clearedCredentials)]).then(() => {
invalidateAuthToken();
openApp();
});
}

Comment thread src/libs/actions/Session/index.ts Outdated
// 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 4b57a79 — replaced the duplicated token-invalidation lines with a call to the existing invalidateAuthToken() helper:

Promise.all([Onyx.merge(ONYXKEYS.CREDENTIALS, clearedCredentials), Onyx.merge(ONYXKEYS.STASHED_CREDENTIALS, clearedCredentials)]).then(() => {
invalidateAuthToken();
openApp();
});
}

@aimane-chnaif

Copy link
Copy Markdown
Contributor

@MelvinBot address #96322 (comment), #96322 (comment) if applicable

…estroy

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team as a code owner July 22, 2026 17:27
@melvin-bot
melvin-bot Bot requested a review from MonilBhavsar July 22, 2026 17:27
@melvin-bot

melvin-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

@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]

@melvin-bot
melvin-bot Bot removed the request for review from a team July 22, 2026 17:27
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Both were applicable — addressed in 4b57a79.

  • Delegate stashed credentials (P2): Confirmed. When connected as a delegate, reauthenticate reads STASHED_CREDENTIALS instead of CREDENTIALS, so clearing only CREDENTIALS would let reauth succeed and restore the original account rather than signing out. invalidateCredentials now clears STASHED_CREDENTIALS too (via Promise.all so both merges resolve before the request fires).
  • CONSISTENCY-3 duplication: Replaced the duplicated token-invalidation lines with a call to the existing invalidateAuthToken() helper.

src/libs/actions/Session/index.ts:1040-1053

Lint and TypeScript checks pass on the changed file.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 MonilBhavsar has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@MonilBhavsar MonilBhavsar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Image

@MonilBhavsar

Copy link
Copy Markdown
Contributor

Going to merge as it's for debugging purpose

@MonilBhavsar
MonilBhavsar merged commit d5ffd73 into main Jul 22, 2026
43 checks passed
@MonilBhavsar
MonilBhavsar deleted the claude-destroyForcesSignOut branch July 22, 2026 19:14
@github-actions

Copy link
Copy Markdown
Contributor

🚧 MonilBhavsar has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Jul 22, 2026
52 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.4.43-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 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 authToken, and firing a request so reauth fails. Both files touched (src/components/TestToolMenu.tsx and src/libs/actions/Session/index.ts) are internal developer/debugging tooling.

This test tool is not a user-facing feature and is not documented anywhere under App/docs/articles. I searched the help site for "Test Tool Menu", "Device credentials", "Invalidate/Destroy credentials", and "Troubleshoot menu" — the only hits are integration troubleshooting guides and a 3DS card-approval article that uses "device credentials" to mean a device passcode/PIN, none of which relate to this developer debug tool.

@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.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.4.43-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants