Skip to content

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

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

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

Conversation

@MelvinBot

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

// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review".
// Please describe what tests you performed that validate your change worked.

Suggested steps:

  1. Create/open a workspace with the Expensify Card feature enabled and Workflows disabled (Workspace settings → More features → turn Workflows off).
  2. Go to Workspace settings → Expensify Card → Issue card → Choose a limit type.
  3. Tap Enable approvals.
  4. Verify you land on the More features page without the Workflows page flashing first.
  5. Repeat with Workflows enabled and verify tapping the link still opens the Workflows page normally.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: The human co-author must fill out the QA tests before marking this PR as "ready for review".
// Please describe what QA needs to do to validate your changes and what areas they need to test for regressions.

  • 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
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 9 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.

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