Skip to content

Fix Not-here page flashing when deleting workspace from Overview - #97261

Open
dilshodmackbook-sketch wants to merge 4 commits into
Expensify:mainfrom
dilshodmackbook-sketch:dilshod/fix-96977-workspace-notfound-flash
Open

Fix Not-here page flashing when deleting workspace from Overview#97261
dilshodmackbook-sketch wants to merge 4 commits into
Expensify:mainfrom
dilshodmackbook-sketch:dilshod/fix-96977-workspace-notfound-flash

Conversation

@dilshodmackbook-sketch

@dilshodmackbook-sketch dilshodmackbook-sketch commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

When deleting a workspace from Workspace → Overview → More → Delete → Delete, the "Hmm... it's not here" (Not found) page flashed briefly before landing on the Workspaces list — most noticeable on mWeb where the page-exit animation is slower.

The Overview page renders inside WorkspacePageWithSections, which decides whether to show FullPageNotFoundView via its own shouldShow memo. Deleting online is a two-step Onyx transition: the policy is first optimistically marked pendingAction: DELETE, then (on backend success) removed from Onyx entirely. Once the policy is gone, the empty-policy branch of shouldShow returns true, and it has no pending-delete guard — so the Not-found view paints on the still-mounted Overview screen while goBackFromInvalidPolicy()'s navigation/exit animation plays out.

This mirrors the transient WorkspaceInitialPage already protects against by latching its not-found flag. WorkspacePageWithSections had no such latch.

The fix detects that the workspace being viewed is the one the user is deleting (it's optimistically pending delete, or it was pending delete last render and is now gone from Onyx) and latches that in state. While latched, shouldShow stays false for the rest of the screen's life, so the Not-found view doesn't flash during the exit animation. It only latches on a real, user-initiated deletion, so genuine "not accessible / not found" cases are unaffected, and offline deletes (where the policy keeps pendingAction: DELETE and is never emptied) keep relying on the existing guard.

Fixed Issues

$ #96977
PROPOSAL: #96977 (comment)

Tests

  1. Log in and open a workspace you own that can be deleted.
  2. Navigate to Workspace → Overview.
  3. Tap More → Delete → Delete to confirm.
  4. Verify the Not-found ("Hmm... it's not here") page does not appear at any point during or after the deletion; the app navigates straight back to the Workspaces list.
  5. Verify that opening a workspace URL you don't have access to (or a non-existent workspace) still shows the Not-found page as expected.
  6. Automated: npx jest tests/ui/WorkspacePageWithSectionsTest.tsx passes, including the two new cases covering the delete transition and the genuine not-found negative case.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline.
  2. Navigate to Workspace → Overview and tap More → Delete → Delete.
  3. Verify the workspace shows as pending delete (greyed out) and the Not-found page does not flash. When back online the deletion is confirmed and you're navigated back without a Not-found flash.

QA Steps

  1. Log in and open a workspace you own.
  2. Navigate to Workspace → Overview.
  3. Tap More → Delete → Delete.
  4. Verify the Not-found ("Hmm... it's not here") page does not appear briefly before landing on the Workspaces list.
  • 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 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 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
Screen.Recording.2026-07-29.at.18.18.49.mov
Android: mWeb Chrome
Screen.Recording.2026-07-29.at.15.08.34.mov
iOS: Native
Screen.Recording.2026-07-29.at.18.23.16.mov
iOS: mWeb Safari
Screen.Recording.2026-07-29.at.15.09.00.mov
MacOS: Chrome / Safari
Screen.Recording.2026-07-29.at.15.06.19.mov

Latch the deleted state in WorkspacePageWithSections so FullPageNotFoundView
does not flash while goBackFromInvalidPolicy()'s exit animation plays out and
the navigation state re-renders the still-mounted Overview screen.

Fixes Expensify#96977

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dilshodmackbook-sketch

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: bbb840df33

ℹ️ 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".

@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: bbb840df33

ℹ️ 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 on lines +183 to +184
const [hasWorkspaceBeenDeleted, setHasWorkspaceBeenDeleted] = useState(false);
if (!hasWorkspaceBeenDeleted && (isPendingDelete || (prevIsPendingDelete && isEmptyObject(policy)))) {

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 Reset delete latch when the policy changes

When the same WorkspacePageWithSections instance is reused for another route.params.policyID after a deletion has been latched, this state never clears, so shouldShow stays forced to false for the new workspace too. In that case an empty or inaccessible replacement workspace renders the normal children instead of the not-found/unauthorized view; key this latch by policyID or clear it when the route policy changes.

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. I reworked the latch so it stores the deleted policyID instead of a plain boolean. hasWorkspaceBeenDeleted is now derived as deletedPolicyID === policyID, so the suppression is scoped to the exact workspace being deleted and clears on its own the moment this still-mounted screen is reused for a different policyID.

I also guarded the pending-delete -> removed-from-Onyx transition with prevPolicyID === policyID. That branch reads prevPolicy, which belongs to the previous render's policyID, so without the guard a policyID switch could re-latch the new workspace off a stale prevPolicy. Now an empty or inaccessible replacement workspace renders the normal not-found view as expected.

Added a test that reuses the same screen instance for a different, inaccessible policyID after a delete and asserts the not-found view shows.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dilshodmackbook-sketch
dilshodmackbook-sketch marked this pull request as ready for review July 29, 2026 10:47
@dilshodmackbook-sketch
dilshodmackbook-sketch requested review from a team as code owners July 29, 2026 10:47
@melvin-bot
melvin-bot Bot requested a review from DylanDylann July 29, 2026 10:48
@melvin-bot

melvin-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

@DylanDylann 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 flaviadefaria and removed request for a team July 29, 2026 10:48
@DylanDylann

Copy link
Copy Markdown
Contributor

@codex review

@DylanDylann

DylanDylann commented Aug 3, 2026

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
Screen.Recording.2026-08-03.at.12.16.16.mov
Android: mWeb Chrome
Screen.Recording.2026-08-03.at.11.58.30.mov
iOS: HybridApp
Screen.Recording.2026-08-03.at.12.15.59.mov
iOS: mWeb Safari
Screen.Recording.2026-08-03.at.11.56.35.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-03.at.11.55.57.mov

@DylanDylann

Copy link
Copy Markdown
Contributor

@dilshodmackbook-sketch Could you merge the latest main too?

Comment on lines +180 to +184
// The workspace we're viewing is being deleted (optimistically pending delete, or pending delete last render
// and now gone from Onyx). Latch it so FullPageNotFoundView doesn't flash while goBackFromInvalidPolicy()'s
// exit animation plays out and the navigation state re-renders this (still-mounted) screen.
// We latch the deleted policyID (rather than a plain boolean) so the suppression is scoped to that specific
// workspace and clears automatically if this still-mounted screen is later reused for a different policyID.

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.

Suggested change
// The workspace we're viewing is being deleted (optimistically pending delete, or pending delete last render
// and now gone from Onyx). Latch it so FullPageNotFoundView doesn't flash while goBackFromInvalidPolicy()'s
// exit animation plays out and the navigation state re-renders this (still-mounted) screen.
// We latch the deleted policyID (rather than a plain boolean) so the suppression is scoped to that specific
// workspace and clears automatically if this still-mounted screen is later reused for a different policyID.

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, removed the long comments and merged the latest main.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 0ccb90ff49

ℹ️ 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".

dilshodmackbook-sketch and others added 2 commits August 3, 2026 11:44
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dilshodmackbook-sketch

Copy link
Copy Markdown
Contributor Author

Done, merged main.

@melvin-bot
melvin-bot Bot requested a review from jasperhuangg August 3, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants