Skip to content

Remove isTrackIntentUser guards from search menu sections - #91252

Merged
arosiclair merged 4 commits into
mainfrom
claude-removeTrackIntentGuardsSearchUI
May 27, 2026
Merged

arosiclair merged 4 commits into
mainfrom
claude-removeTrackIntentGuardsSearchUI

Conversation

@MelvinBot

@MelvinBot MelvinBot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Track-intent users who later enable approvals and/or payments under Workflows don't see the submit, approve, pay, or export menu items on the Reports/Search page. This is because isTrackIntentUser — based on the immutable NVP_INTRO_SELECTED onboarding choice — unconditionally gates these items in createTypeMenuSections().

The policy-level checks in getSuggestedSearchesVisibility() already correctly evaluate whether approvals and payments are enabled for the user's policies. This PR removes the three isTrackIntentUser guards and lets the existing policy checks drive visibility. It also cleans up the now-unused isTrackIntentUser parameter, selector, and Onyx subscription.

Fixed Issues

$ #91237
PROPOSAL: #91237 (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 validates your changed worked.

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Create a new user and select "Track expense for my business" in onboarding
  • Go to "Spend"
  • Confirm there is no "Drafts" or "Needs Approval" in the LHN for search
  • Turn on Workflows and Approvals
  • Return to "Spend"
  • Confirm "Drafts" and "Needs Approval" ARE in the LHN for search
image
  • 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 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

Track-intent users who later enable approvals and/or payments under
Workflows don't see submit/approve/pay/export menu items on Reports
page because the isTrackIntentUser guard unconditionally hides them.

The policy-level checks in getSuggestedSearchesVisibility() already
correctly evaluate whether these features are enabled. Removing the
static onboarding-based guard lets those checks drive visibility.

Co-authored-by: Daniel Gale-Rosen <dangrous@users.noreply.github.com>
@codecov

codecov Bot commented May 20, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/hooks/useSearchTypeMenuSections.ts 87.27% <ø> (ø)
src/libs/SearchUIUtils.ts 64.22% <100.00%> (+0.07%) ⬆️
... and 252 files with indirect coverage changes

@dangrous
dangrous marked this pull request as ready for review May 21, 2026 13:36
@dangrous
dangrous requested a review from a team as a code owner May 21, 2026 13:36
@melvin-bot
melvin-bot Bot requested review from joekaufmanexpensify and truph01 and removed request for a team May 21, 2026 13:36
@melvin-bot

melvin-bot Bot commented May 21, 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]

@dangrous

Copy link
Copy Markdown
Contributor

@MelvinBot can you please update tests appropriately to maintain proper coverage

Add reimbursementChoice and reimburser to the mock policy so
isPolicyPayer returns true, and restore the PAY assertion that
was dropped when removing the isTrackIntentUser guard.

Co-authored-by: Daniel Gale-Rosen <dangrous@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team as a code owner May 21, 2026 14:53
@melvin-bot
melvin-bot Bot requested review from dangrous and hoangzinh and removed request for a team May 21, 2026 14:53
@melvin-bot

melvin-bot Bot commented May 21, 2026

Copy link
Copy Markdown

@hoangzinh @dangrous One of you needs to 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]

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Updated the test to properly cover all four menu keys (submit, approve, pay, export):

  1. Added reimbursementChoice: REIMBURSEMENT_YES and reimburser to the mock policy so isPolicyPayer returns true — this makes PAY visible
  2. Restored the PAY assertion that was dropped when converting the old track-intent negative test into the new positive test

The existing test at line 6580 ("should not show todo section when user has no appropriate permissions") already covers the negative case — it uses a personal policy without approvals and verifies that none of the TODO keys (submit/approve/pay/export) appear.

@truph01

truph01 commented May 21, 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • 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 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)
  • 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
  • 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.
  • 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.
  • 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-05-25.at.13.49.19.mov
Android: mWeb Chrome
Screen.Recording.2026-05-25.at.10.52.19.mov
iOS: HybridApp
Screen.Recording.2026-05-25.at.14.17.16.mov
iOS: mWeb Safari
Screen.Recording.2026-05-25.at.13.52.02.mov
MacOS: Chrome / Safari
Screen.Recording.2026-05-25.at.10.49.27.mov

@truph01

truph01 commented May 21, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

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

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

Makes sense 👍

@truph01

truph01 commented May 22, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot In the test case's step 3:

Confirm there is no "Drafts" or "Needs Approval" in the LHN for search

But when testing, the Drafts option is still visible. Could you investigate?

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Good catch. "Drafts" is still visible because the SUBMIT visibility check doesn't depend on approval settings — it only requires the policy to be a TEAM or CORPORATE type.

Why it happens: When a track-intent user onboards, a TEAM policy is created (Policy.ts:2595). The SUBMIT (Drafts) visibility is gated solely on isPaidPolicy, which returns true for any TEAM/CORPORATE policy. The old isTrackIntentUser guard was specifically there to override this for track-intent users.

Additionally, the track-intent workspace is created with approvalMode: BASIC (Policy.ts:2632), so "Needs Approval" (APPROVE) will likely also still be visible in step 3.

The core issue: This PR assumed the policy-level checks in getSuggestedSearchesVisibility() would correctly hide these items for track-intent users, but the SUBMIT check only looks at policy type, not whether workflows/approvals are actually enabled. Since track-intent users get a TEAM policy by default, removing the isTrackIntentUser guard exposes items that were intentionally hidden.

The fix likely needs to either:

  1. Make getSuggestedSearchesVisibility() more granular — e.g., check whether the policy actually has approval workflows enabled before showing SUBMIT/APPROVE, rather than just checking isPaidPolicy
  2. Or keep a targeted guard for track-intent users until they enable workflows

@truph01

truph01 commented May 22, 2026

Copy link
Copy Markdown
Contributor

@dangrous Could you take a look into this #91252 (comment)?

@dangrous

Copy link
Copy Markdown
Contributor

@MelvinBot to be safe, let's update that one to check if they're not (track intent with workflows disabled) so we can cover both bases for now. I'm not sure what the intended behavior is, and that will keep it as expected in this PR

…flows disabled

Instead of completely removing the isTrackIntentUser guard, update it to
check !(isTrackIntentUser && !hasAnyPolicyWithWorkflowsEnabled). This hides
SUBMIT, APPROVE, PAY, EXPORT, and TOP_SPENDERS only when the user is a
track-intent user AND none of their policies have workflows enabled.

Co-authored-by: Daniel Gale-Rosen <dangrous@users.noreply.github.com>
@dangrous

Copy link
Copy Markdown
Contributor

lol, was trying to get an internal reviewer. That did not work, sigh. Maybe @truph01 if you approve again it'll ask someone else?

@truph01

truph01 commented May 26, 2026

Copy link
Copy Markdown
Contributor

@dangrous I approved again

@dylanexpensify
dylanexpensify requested a review from a team May 26, 2026 18:47
@melvin-bot
melvin-bot Bot requested review from truph01 and removed request for a team May 26, 2026 18:47
@melvin-bot

This comment was marked as duplicate.

@dylanexpensify
dylanexpensify requested a review from a team May 26, 2026 18:47
@melvin-bot
melvin-bot Bot requested a review from arosiclair May 26, 2026 18:48
@melvin-bot

melvin-bot Bot commented May 26, 2026

Copy link
Copy Markdown

@arosiclair 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 May 26, 2026 18:48
@arosiclair
arosiclair merged commit 9010a36 into main May 27, 2026
42 checks passed
@arosiclair
arosiclair deleted the claude-removeTrackIntentGuardsSearchUI branch May 27, 2026 12:49
@melvin-bot melvin-bot Bot added the Emergency label May 27, 2026
@melvin-bot

melvin-bot Bot commented May 27, 2026

Copy link
Copy Markdown

@arosiclair looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@arosiclair

Copy link
Copy Markdown
Contributor

Everything was passing

@github-actions

Copy link
Copy Markdown
Contributor

🚧 @arosiclair 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 May 27, 2026
75 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/arosiclair in version: 9.3.84-0 🚀

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

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor Author

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

No help site changes are required.

This PR removes isTrackIntentUser guards from search menu sections so that track-intent users who later enable Workflows see the submit, approve, pay, export, and top spenders items. The existing help site articles already describe visibility of these features in terms of user role and enabled workspace features — not onboarding intent:

The docs are already aligned with the post-fix behavior (feature/role checks drive visibility). No updates needed.

@dangrous, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/arosiclair in version: 9.3.86-0 🚀

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

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I reviewed the changes in this PR against all help site articles under App/docs/articles and no help site changes are required.

Why: This PR fixes a bug where track-intent users couldn't see Submit, Approve, Pay, Export, and Top Spenders search items after enabling Workflows. The existing help docs already describe visibility based on role (submitter, approver, admin) — not onboarding intent — so they already reflect the correct post-fix behavior:

  • Use-Search-Shortcuts.md — documents role-based shortcut visibility
  • Track-Expenses.md — covers expense tracking without submitting
  • Insights articles (Top Spenders, Spend over time, etc.) — describe access by role

No article referenced the previous buggy behavior, so no updates are needed.

@dangrous, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/arosiclair in version: 9.3.88-0 🚀

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

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor Author

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

No help site changes are required.

This PR fixes a bug where track-intent users who later enable Workflows couldn't see the submit, approve, pay, export, and top spenders menu items on the Spend page. The fix changes an unconditional isTrackIntentUser guard to isTrackIntentWithWorkflowsDisabled, so the items now correctly appear when workflows are enabled.

The relevant help site articles already describe the correct (post-fix) behavior:

  • Use Search Shortcuts describes shortcut visibility based on roles (Submitters → Drafts, Approvers → Needs approval, Admins → Ready to pay) without referencing the track-intent limitation.
  • Accounting Search Shortcuts describes accounting shortcuts requiring approvals and reimbursements/cards — no track-intent mention.
  • Workspace Workflows describes enabling workflows — no mention of search shortcut visibility.

Since the articles already describe the intended behavior and none of them reference the track-intent user limitation that this PR removes, no documentation updates are needed.

@dangrous, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.3.88-2 🚀

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

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.

7 participants