Skip to content

Fix flash of disabled feature page before redirect to More features - #98549

Open
MelvinBot wants to merge 4 commits into
mainfrom
claude-fixWorkflowsPageFlashOnDisabledFeature
Open

Fix flash of disabled feature page before redirect to More features#98549
MelvinBot wants to merge 4 commits into
mainfrom
claude-fixWorkflowsPageFlashOnDisabledFeature

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

The Workflows page (and any other feature-gated workspace page) briefly flashes before redirecting to More features when its feature is disabled. Repro: on a workspace with Expensify Card enabled but Workflows disabled, open Expensify Card → Issue card → Choose a limit type → tap Enable approvals. The link points at the Workflows page, but since Workflows is disabled the page is shown for a frame before navigating to More features.

Root cause: AccessOrNotFoundWrapper mounts the target page's children first and only redirects afterwards, from inside a useEffect that further defers navigation to the microtask queue. So a disabled feature page renders for at least one frame before goBack fires — the visible flash. This is a property of the wrapper, so it isn't specific to the Expensify Card flow.

Change: the redirect condition is extracted into a single shouldRedirectToMoreFeatures derived value, reused as the existing useEffect guard (behavior unchanged, including the pendingField/offline guard that protects against transient feature-state changes during workspace creation). During render, when that value is true, the wrapper now returns a FullscreenLoadingIndicator instead of the page's children, so the disabled page is never painted and there is no flash. This fixes the flash centrally for every feature-gated page routed through the wrapper.

Fixed Issues

$ #98504
PROPOSAL: #98504 (comment)

Tests

Retest the linked issue

  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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: truph01 <truph01@users.noreply.github.com>
Co-authored-by: truph01 <truph01@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Fixed the failing Oxfmt check. The shouldRedirectToMoreFeatures declaration was wrapped across two lines, but it fits within the 190-char print width, so Oxfmt wanted it on a single line. Ran npm run fmt and pushed the change.

Details

The Oxfmt job runs oxfmt --write . and fails if there's a diff. It flagged only src/pages/workspace/AccessOrNotFoundWrapper.tsx:

-    const shouldRedirectToMoreFeatures =
-        isFocused && !isEmptyObject(policy) && !isFeatureEnabled && !(pendingField && !isOffline) && !shouldShowNotFoundPage;
+    const shouldRedirectToMoreFeatures = isFocused && !isEmptyObject(policy) && !isFeatureEnabled && !(pendingField && !isOffline) && !shouldShowNotFoundPage;

No logic change — formatting only.

The other red checks are not actionable code failures: Check independent approval and checklist are process/review gates, not test/build failures.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

All actionable checks are now green — the Oxfmt check that was failing has been fixed (formatting-only change, already pushed).

The two checks still showing red are process gates, not code failures, and can't be fixed with a code push:

  • PR Author Checklist / checklist — needs the author to tick the checklist boxes in the PR description.
  • Check independent approval — clears once the PR gets the required review approval.

The remaining test, typecheck, and perf jobs were still running at the time of this check.

Co-authored-by: truph01 <truph01@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Fixed the failing test (job 7) — the tests/ui/AssignCardFeed.tsx suite (19 tests) was rendering blank because this PR's change now correctly hides a feature-gated page when its feature is disabled, and the test policies never enabled Company Cards.

Details

AssigneeStep and the confirmation step wrap their content in AccessOrNotFoundWrapper with featureName={CONST.POLICY.MORE_FEATURES.ARE_COMPANY_CARDS_ENABLED}.

The test policies were built from getFakePolicy(), which doesn't set areCompanyCardsEnabled. Before this PR, the wrapper mounted the page's children and only redirected afterward via a microtask, so the tests could still find the elements. This PR's fix intentionally returns a FullscreenLoadingIndicator during render when the feature is disabled — so the page no longer renders and every getByText / getByTestId assertion failed with testID="" (nothing rendered).

The fix adds areCompanyCardsEnabled: true to each test policy, which matches reality (these pages are only reachable when Company Cards is enabled). Full suite now passes locally: 21 passed, 21 total.

The remaining red checks (Check independent approval, checklist) are process/review gates, not code failures.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

There's nothing left for me to fix here — the Oxfmt check I fixed in the previous run is now green.

The only two remaining red checks are process/review gates that require human action, not code changes:

  • Verify peer review / Check independent approval — needs an independent reviewer to approve the PR.
  • PR Author Checklist / checklist — needs the PR Author Checklist in the description ticked off (the human co-author still needs to fill in the Tests/QA sections and check the boxes).

Once those are addressed by a person, all checks should pass.

@codecov

codecov Bot commented Aug 13, 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/pages/workspace/AccessOrNotFoundWrapper.tsx 82.43% <80.00%> (-0.67%) ⬇️
... and 133 files with indirect coverage changes

@truph01

truph01 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@codex review

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No actionable check failures remain. The Oxfmt check is now passing after the earlier formatting fix.

The two remaining red checks are process/review gates, not code failures, so there's nothing for me to push:

  • PR Author Checklist / checklist — needs the human co-author to complete the checklist and fill in the Tests/QA sections.
  • Check independent approval — needs reviewer approval, not a code change.

The performance tests (baseline-perf-tests / branch-perf-tests) are still running, not failed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 1bb089b60c

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

@truph01

truph01 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot Mark this PR as ready for review

@MelvinBot
MelvinBot marked this pull request as ready for review August 13, 2026 08:03
@MelvinBot
MelvinBot requested a review from a team as a code owner August 13, 2026 08:03
@melvin-bot
melvin-bot Bot requested review from garrettmknight and truph01 and removed request for a team August 13, 2026 08:03
@melvin-bot

melvin-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

@truph01 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 August 13, 2026 08:03
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Marked this PR as ready for review.

Before flipping it, I verified the core fix on web: with a workspace that had Expensify Card enabled and Workflows disabled, navigating to the disabled Workflows settings page now redirects to More features without rendering (flashing) the disabled page — a FullscreenLoadingIndicator shows briefly instead of the Workflows content, matching the intended behavior.

Testing notes
  • ✅ Created a workspace (admin), enabled Expensify Card, kept Workflows off.
  • ✅ Directly navigating to the disabled Workflows URL redirected straight to More features without showing Workflows page content.
  • ⚠️ The exact Issue card → Choose a limit type → Enable approvals deep link couldn't be reached in the test session — issuing a card requires a validated bank account, which hit an MFA/magic-code wall that's out of scope for automated testing. This is an environment limitation, not a regression.

Screenshots from the run are attached in a separate comment.

⚠️ Heads up truph01: the Tests and QA Steps sections in the PR body still contain // TODO placeholders for the human co-author to fill in. Please complete those (and the author checklist) so reviewers/QA have concrete steps.

// The feature linked to this page is disabled, so the redirect effect above will navigate to the More Features page.
// Render a loader instead of the page's children so the disabled page is never shown for a frame (avoids a visible flash).
if (shouldRedirectToMoreFeatures) {
return <FullscreenLoadingIndicator />;

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.

❌ UI-1 (docs)

This newly added FullscreenLoadingIndicator is returned from a conditional branch with no navigation component (no HeaderWithBackButton or close button) in the same return. If the redirect ever hangs, the user has no escape route because there is no visible navigation. Per UI-1, a full-screen loader rendered without accompanying navigation should set shouldUseGoBackButton so an emergency "Go Back" button appears after a timeout.

if (shouldRedirectToMoreFeatures) {
    return <FullscreenLoadingIndicator shouldUseGoBackButton />;
}

Reviewed at: 1bb089b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

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.

@truph01 let's address this

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.

@MelvinBot Check this

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.

Addressed. The UI-1 suggestion is valid — this loader branch has no navigation, so if the microtask redirect ever hung the user would be stuck. Added shouldUseGoBackButton so the emergency "Go Back" button appears after a timeout:

if (shouldRedirectToMoreFeatures) {
    return <FullscreenLoadingIndicator shouldUseGoBackButton />;
}

In the normal fast-redirect path nothing changes (the button only shows after the timeout). ESLint passes on the file. Pushed in 2afe348.

I scoped the change to the new branch only; the pre-existing shouldShowFullScreenLoadingIndicator loader above it wasn't touched by this PR, so I left it as-is.

garrettmknight
garrettmknight previously approved these changes Aug 13, 2026
@MelvinBot

Copy link
Copy Markdown
Contributor Author

The only failing checks are PR Author Checklist and PR Reviewer Checklist — every substantive check (Bun tests, test jobs 1–8, typecheck, ESLint, Oxfmt, React Compiler, Storybook, perf) is green.

Both are failing by design, not because of a code problem:

  • PR Author ChecklistPR Author Checklist is not completely filled out. Please check every box to verify you've thought about the item.
  • PR Reviewer Checklist → same underlying automation, waiting on the reviewer checklist.

There's no code fix to push here. These clear once a human completes the checklists:

  1. The human co-author fills out the Tests / QA Steps sections (they're still // TODO placeholders) and checks every box in the PR Author Checklist.
  2. The reviewer completes the PR Reviewer Checklist during review.

So nothing is broken in the branch — the reds are just the unchecked author/reviewer checklists.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Still the same as my earlier reply — nothing new is broken.

The only two red checks are PR Author Checklist and PR Reviewer Checklist. Every substantive check (Bun tests, all 8 test jobs, typecheck, ESLint, Oxfmt, React Compiler, Storybook, perf) is passing.

These two fail by design, not because of a code problem: PR Author Checklist is not completely filled out. Please check every box. There's no code fix for me to push. They clear once:

  1. The human co-author fills out the Tests / QA Steps sections (still // TODO placeholders) and checks every box in the PR Author Checklist.
  2. The reviewer completes the PR Reviewer Checklist during review.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Still the same situation as my previous analysis: the only failing checks are PR Author Checklist and PR Reviewer Checklist. Every substantive check (Bun tests, all test jobs, typecheck, ESLint, Oxfmt, React Compiler, Storybook, perf) is green.

Both fail by design, not because of a code problem — the Author Checklist errors with PR Author Checklist is not completely filled out. Please check every box. There's nothing for me to push here.

To clear the reds, a human needs to:

  1. Fill out the Tests / QA Steps sections (currently // TODO placeholders) and check every box in the PR Author Checklist.
  2. Have the reviewer complete the PR Reviewer Checklist during review.

Co-authored-by: truph01 <truph01@users.noreply.github.com>
@melvin-bot

melvin-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

@youssef-lr 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 August 13, 2026 17:10
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Re-checked — the currently-failing checks are all ones that fail by design, not code problems:

  • PR Author Checklist → fails until the author checks every box in the checklist.
  • PR Reviewer Checklist → fails until the reviewer completes their checklist during review.
  • Check independent approval → fails until the PR has an independent reviewer approval.

The rest of the suite that has finished is green, and several checks (perf tests, ESLint, build) are still re-running from the latest push.

There's nothing for me to fix in the branch. These three clear on their own once (1) the human co-author fills out the Tests/QA Steps sections and checks the author checklist, and (2) a reviewer approves and completes the reviewer checklist.

@roryabraham roryabraham self-assigned this Aug 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

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

@roryabraham

Copy link
Copy Markdown
Contributor

requested retest on the AdHoc build: https://expensify.slack.com/archives/C09V78U42D8/p1786669656109099

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.

5 participants