Skip to content

[cp stag] Fix Not Here page when opening card spend rules on a Collect workspace - #97704

Merged
JS00001 merged 4 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue-97632
Aug 3, 2026
Merged

[cp stag] Fix Not Here page when opening card spend rules on a Collect workspace#97704
JS00001 merged 4 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue-97632

Conversation

@Krishna2323

@Krishna2323 Krishna2323 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

#95310 added the CONTROL access variant to the spend rule pages to keep Card restrictions Control-only. However, access variants in AccessOrNotFoundWrapper are ANDed, so they can only render Not Found when any required variant is missing. As a result, Collect workspaces were hard-blocked from these pages.

This also bypassed the existing feature disabled → More features upgrade flow that these pages previously used.

The main entry point affected is Wallet → Card details → Edit spend rules. That action is available to any workspace admin and doesn't perform any plan or feature checks, so it bypasses the upgrade gating already implemented by the Rules pages.

Fix

  • Remove the CONTROL access variant from the three spend rule pages.
  • Redirect Collect admins to the Control upgrade page instead, matching the behavior of the Rules page for other Control-only features.
  • Use Navigation.dismissModalAndReplace so pressing Back from the upgrade flow doesn't return to a page Collect workspaces can't access.
  • Preserve the Wallet flow by passing the current route as backTo, so after upgrading the user is returned to where they started.

Fixed Issues

$ #97632
PROPOSAL:

Tests

  1. Collect workspace + card issued + Rules feature disabled
    • Go to Wallet → Card → Edit spend rules.
    • Verify: You are redirected to the More features upgrade page.
  2. Collect workspace + card issued + Rules feature enabled
    • Go to Wallet → Card → Edit spend rules.
    • Verify: The upgrade page is shown (previously this was the "Not Here" page).
    • Complete the upgrade.
    • Verify: You are redirected back to the Spend rules page and can use it normally.
  3. Control workspace + Rules feature enabled
    • Go to Wallet → Card → Edit spend rules.
    • Verify: The page opens normally and changes can be saved.
  4. Control workspace + Rules feature disabled
    • Go to Wallet → Card → Edit spend rules.
    • Verify: You are redirected to the More features page (same behavior as before this PR).
  5. Control workspace
    • Go to Rules → Card restrictions.
    • Add and edit a rule.
    • Verify: The card and category pickers work correctly.
  • Verify that no errors appear in the JS console

Offline tests

  • Same as test

QA Steps

  • Same as test

  • 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
    • MacOS: Desktop
  • 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
web_chrome_with_beta.mp4
web_chrome_without_beta.mp4

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323
Krishna2323 marked this pull request as ready for review August 3, 2026 16:08
@Krishna2323
Krishna2323 requested review from a team as code owners August 3, 2026 16:08
@melvin-bot
melvin-bot Bot requested review from joekaufmanexpensify and situchan and removed request for a team August 3, 2026 16:08
@melvin-bot

melvin-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

@situchan 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 3, 2026 16:08
@situchan

situchan 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
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
fix.mov

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...tings/Wallet/WalletExpensifyCardSpendRulesPage.tsx 0.00% <0.00%> (ø)
...s/workspace/rules/SpendRules/SpendRuleCardPage.tsx 0.00% <0.00%> (ø)
...rkspace/rules/SpendRules/SpendRuleCategoryPage.tsx 0.00% <0.00%> (ø)
src/libs/PolicyUtils.ts 77.27% <0.00%> (ø)
...s/workspace/rules/SpendRules/SpendRulePageBase.tsx 0.00% <0.00%> (ø)
src/hooks/useControlOnlyRuleUpgradeRedirect.ts 0.00% <0.00%> (ø)
... and 93 files with indirect coverage changes

@situchan

situchan commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Bug: Upgrade modal briefly shows before navigating to More features

Screen.Recording.2026-08-03.at.5.14.28.PM.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: f64b14f605

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/pages/workspace/rules/SpendRules/SpendRuleCardPage.tsx
…ckers

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323

Copy link
Copy Markdown
Contributor Author

Bug: Upgrade modal briefly shows before navigating to More features

Fixed

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@situchan

situchan commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

@situchan

situchan commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot review

// Replace rather than push: Back from the upgrade page must not land on a page Collect can't use.
hasRedirectedToUpgrade.current = tryNavigateToControlPolicyUpgrade(policy, CONST.UPGRADE_FEATURE_INTRO_MAPPING.rules.alias, upgradeBackTo, true);
// `policy` changes identity on unrelated writes, so gate on the derived flags instead.
// eslint-disable-next-line react-hooks/exhaustive-deps

@situchan situchan Aug 3, 2026

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.

Is this comment not avoidable?
And I think this should be added to seatbelt, not here

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.

Policy is in the deps now. The hasRedirectedToUpgrade ref already short-circuits re-runs after the first successful navigation.

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Reviewed the code. The approach is sound and I don't see a blocker — the fix correctly unblocks Collect while preserving Control-only gating. A few notes below.

Why the fix is correct

  • accessVariants are ANDed in AccessOrNotFoundWrapper, and PAID maps to isGroupPolicy while CONTROL maps to isControlPolicy. So [PAID, CONTROL] resolved to Control-only and hard-blocked Collect with Not Found. Dropping to [PAID] lets Collect group policies render, and the new hook routes them to the upgrade flow instead — matching how the Rules page already handles other Control-only features. ✅
  • The isRulesFeatureEnabled guard is the right fix for the earlier flash you reported: when Rules is disabled the hook bails and lets the wrapper redirect to More features, so the upgrade page no longer flashes on the way there. ✅
  • forceReplace: true in tryNavigateToControlPolicyUpgrade correctly keeps Back from landing on a page Collect can't use, and the Wallet entry point passes upgradeBackTo so the user returns to where they started. ✅
  • The Codex deep-link gap on the picker pages was addressed by adding the hook to both SpendRuleCardPage and SpendRuleCategoryPage, so /rules/spend-rules/:ruleID/card and /category deep links are gated too. ✅

Worth confirming (non-blocking)

  1. Unit tests — the author checklist marks "I added unit tests," but no test file is in the diff. The gating logic here (the hook + tryNavigateToControlPolicyUpgrade) is exactly the kind of navigation branch that silently regresses; a small unit test covering Collect-vs-Control × Rules-enabled-vs-disabled would be worthwhile.
  2. Gating is now per-page — Control-only gating for these pages/pickers now lives in the useControlOnlyRuleUpgradeRedirect hook rather than centrally in the wrapper. Any future entry point that renders a spend-rule page or picker must remember to call the hook or it silently bypasses the upgrade gate. Worth a brief note/comment so it isn't lost.
  3. One-frame flash — the redirect happens in a useEffect after first paint, so a Collect admin with Rules enabled may briefly see the spend-rules page before the forceReplace. Minor and likely acceptable, but worth a glance during QA.
Testing note

I did not runtime-reproduce the exact flow — it requires a Collect workspace with an Expensify card issued and the RULES_REVAMP beta enabled (arePolicyRulesEnabled returns false for Collect unless that beta is on), which isn't available on a generic test account. Recommend QA verify the 5 test scenarios in the PR body, especially #2 (Collect + Rules enabled → upgrade page → returns to Spend rules after upgrade) and #5 (Control picker still works). CI is green aside from the pending perf tests.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 363203b3fa

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

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@situchan

situchan commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

On native, Add rule page briefly shows

Screen.Recording.2026-08-03.at.5.58.06.PM.mov

@JS00001
JS00001 self-requested a review August 3, 2026 17:08
@situchan

situchan commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

On native, Add rule page briefly shows

Screen.Recording.2026-08-03.at.5.58.06.PM.mov

I reproduced this in playstore version v9.4.46-10. Not blocker as happening on production

@JS00001
JS00001 merged commit 6f20c4d into Expensify:main Aug 3, 2026
35 of 36 checks passed
@OSBotify

OSBotify commented Aug 3, 2026

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.

@JS00001 JS00001 changed the title Fix Not Here page when opening card spend rules on a Collect workspace [cp stag] Fix Not Here page when opening card spend rules on a Collect workspace Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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

OSBotify pushed a commit that referenced this pull request Aug 3, 2026
Fix Not Here page when opening card spend rules on a Collect workspace

(cherry picked from commit 6f20c4d)

(cherry-picked to staging by arosiclair)
@OSBotify OSBotify added the CP Staging marks PRs that have been CP'd to staging label Aug 3, 2026
@OSBotify

OSBotify commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/arosiclair in version: 9.4.48-3 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — no docs changes required

I reviewed the changes in this PR against the help site articles under docs/articles.

Conclusion: No help-site updates are needed.

Why: This is a navigation/access-control bug fix. It changes where a Collect admin lands when they open a Control-only spend rules page — a clean Control upgrade page instead of the "Not Here" dead-end — and preserves the correct Back behavior. It does not add, rename, or change any user-facing feature, tab, setting, button label, or documented flow.

The behavior this PR touches is already accurately reflected in the docs:

  • Workspace-Rules.md already states rules are Control-plan only: "Only Workspace Admins on the Control plan can enable, update, or disable workspace rules."
  • Expensify-Card-Spend-Rules.md documents the spend-rule creation/edit/delete flow, which is unchanged by this PR.

The Control-plan requirement predates this PR (it was established in #95310); this PR only fixes how Collect workspaces are routed to the upgrade path. Since no PR is being created, there is no linked help site PR to review.

@OSBotify

OSBotify commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.4.48-3 🚀

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

Bundle Size Analysis (Sentry):

@OSBotify

OSBotify commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/arosiclair in version: 9.4.49-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Help site review: no changes required.

This PR is an access-gating bug fix, not a user-facing feature or copy change, so nothing under docs/articles needs updating.

Why no docs update is needed

What the PR changes: It removes the CONTROL accessVariant from the three spend-rule pages (which was hard-blocking Collect workspaces with a "Not Here" page) and instead redirects Collect admins to the Control upgrade page via the new useControlOnlyRuleUpgradeRedirect hook. All changes are navigation/gating logic — there are no src/languages/* copy changes, no new UI labels, and no change to the documented create/edit/delete Spend rule workflow.

The plan requirement it enforces is already documented. The behavior confirms Expensify Card Spend rules require the Control plan (Collect admins are sent to the upgrade flow). The help site already covers this:

Since Rules are Control-only and Spend rules require Rules, the article's stated requirement already implies the Control plan. The PR simply fixes the how you're blocked (upgrade prompt vs. a dead-end error page) — an internal UX correction that the help articles don't document.

@Krishna2323, if you'd still like the Spend rules article to call out the Control plan requirement explicitly (rather than by implication via the Workspace Rules link), let me know and I'll open a draft docs PR for that clarification. Otherwise no action is needed here.

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

Labels

CP Staging marks PRs that have been CP'd to staging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants