Skip to content

Revert "Scope Top Spenders suggested search to eligible workspace policyIDs" - #99907

Merged
luacmartins merged 3 commits into
mainfrom
claude-revertTopSpendersPolicyScope
Sep 8, 2026
Merged

luacmartins merged 3 commits into
mainfrom
claude-revertTopSpendersPolicyScope

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Reverts #95593 ("Scope Top Spenders suggested search to eligible workspace policyIDs"), which was merged as 241cc85678e9e0b2b3f2fcaef2ef239b490dd0d4.

That PR fixed the individual-chat expense leakage on the frontend, by collecting the Top Spenders-eligible policyIDs and adding them as a policyID: filter on the suggested-search query. Per the discussion on the linked issue, we're backing that out:

  • Top Spenders is only one of several workspace insights with the same leakage problem, so a per-insight frontend filter is short-sighted.
  • The UX of the implicit workspace filter is unpredictable.
  • The fix belongs on the backend instead — excluding expenses on IOU reports from the suggested-search insights, which are a workspace feature.

What this revert does:

  • src/libs/SearchUIUtils.ts — removes the topSpendersPolicyIDs parameter from getSuggestedSearches and the ...(topSpendersPolicyIDs.length > 0 ? {policyID: topSpendersPolicyIDs} : {}) spread from the Top Spenders query; removes topSpendersPolicyIDs from getSuggestedSearchesVisibility's return value and the per-policy collection; keeps main's for…of loop (see the note below).
  • src/components/Search/SearchQueryProvider.tsx — drops the useOnyx(ONYXKEYS.COLLECTION.POLICY) read and the useMemo that called getSuggestedSearchesVisibility just to derive the IDs.
  • src/pages/home/InsightsSection/useHomeInsightConfigs.ts and tests/ — drop the now-removed argument at the remaining call sites.

Two spots needed manual conflict resolution because main moved since #95593 merged; both keep the newer main behavior and only remove the reverted code:

  • getSuggestedSearchesVisibility gained an isTrackIntentUser param and hasGroupPoliciesWithExpenseChat was renamed to hasEligibleGroupPolicies.
  • getSuggestedSearches gained an activeExpensifyCardFeedID param; it keeps that and just loses topSpendersPolicyIDs, so it is now the 4th argument at every call site.

Note on the loop shape: #95593 converted the Object.values(policies).some(...) loop into a for…of purely so it could collect every eligible policyID. A strict revert would restore the .some() early-return short-circuit, but that condition predates both shouldShowSpendOverTimeSuggestion and shouldShowViolationsBySubmitterSuggestion, so it would let the loop exit before evaluating either flag for later policies. Since there is no "original" behavior to restore for those flags, this PR keeps main's for…of loop and only removes the topSpendersPolicyIDs collection. The loop body is otherwise identical to main.

Fixed Issues

$ #90294
PROPOSAL: #90294 (comment)

Tests

  1. Navigate to "Spend" > "Top Spenders".
  2. Open "Top spenders" and confirm the search runs and the URL/query no longer contains a policyID: filter.
  • Verify that no errors appear in the JS console

Offline tests

N/A — this change only affects how a search query string is built.

QA Steps

Same as tests.

Note for QA: this is an intentional revert, so the original issue's symptom (an individual-chat expense appearing under "Top spenders") is expected to come back. It will be fixed on the backend instead.

  • 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

Platform recordings below were captured by abdulrahuman5196 while completing the reviewer checklist.

Android: Native
Screen.Recording.2026-09-09.at.1.08.29.AM.mov
Android: mWeb Chrome
Screen.Recording.2026-09-09.at.1.10.21.AM.mov
iOS: Native
Screen.Recording.2026-09-09.at.12.54.22.AM.mov
iOS: mWeb Safari
Screen.Recording.2026-09-09.at.12.57.30.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-09.at.12.36.23.AM.mov

…licyScope"

This reverts commit 241cc85, reversing
changes made to be5e677.

Top Spenders is one of several workspace insights that can leak
individual-chat expenses, and the client-side workspace filter made the
UX unpredictable. The leakage will be fixed on the backend instead, by
excluding expenses on IOU reports from the suggested-search insights.
@MelvinBot
MelvinBot requested a review from a team August 31, 2026 13:56
@melvin-bot melvin-bot Bot added Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web labels Aug 31, 2026
@codecov

codecov Bot commented Aug 31, 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/components/Search/SearchQueryProvider.tsx 100.00% <100.00%> (ø)
src/libs/SearchUIUtils.ts 69.72% <ø> (-0.04%) ⬇️
...ages/home/InsightsSection/useHomeInsightConfigs.ts 11.11% <0.00%> (ø)
... and 200 files with indirect coverage changes

@MelvinBot

MelvinBot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Ran the PR's testing steps on Android (standalone NewDot) from this branch (claude-revertTopSpendersPolicyScope @ ef4e43a).

Result: pass — signed in as an admin of a group workspace with 2 members; all four Spend insights (Spend over time, Top spenders, Top categories, Top merchants) rendered and opened without crashing. Top spenders applied only Status and Date filters — no workspace/policyID filter — which is the expected post-revert behavior.

Step Status Observation
Sign in as admin of a group workspace with ≥2 members ✅ pass Workspace Members showed "Total workspace members: 2" — the test user as Owner plus one invited Member. The account had no group workspace, so onboarding created a Collect workspace and a second member was invited.
Navigate to "Spend"; insights menu renders (Spend over time, Top spenders, Top categories, Top merchants) with no crash ✅ pass All four insight tabs appeared in the Spend type menu alongside Reports/Expenses/Drafts/Needs approval/Ready to pay/Cash accruals/My expenses. App stayed responsive.
Open "Top spenders"; search runs and query no longer contains a policyID: filter ✅ pass Search ran and returned the "Nothing to show" empty state. Filter chips showed only Status: Draft, Outstanding, Approved, Paid, Done and Date: Last month — no workspace/policy chip, and the Filters screen had no policy value set. For contrast, the Expenses tab's recent-search entry still carried an explicit workspace:"..." clause.
Other insights (Top categories, Top merchants, Spend over time) still open and return results ✅ pass Each opened cleanly and rendered the "Nothing to show" empty state — expected, since the fresh workspace has no expenses. No crashes or errors.

No console errors were observed.

⚠️ One caveat worth flagging: the workspace was brand new with no expenses, so every insight returned an empty state. That proves the insights open and query without crashing, but it does not exercise the result rendering or confirm that individual-chat expenses now reappear under Top spenders (the intentional regression this revert reintroduces). If you want that confirmed, it needs an account with existing expense data.

Evidence (6)

Workspace Members screen showing 2 total members (Owner + invited Member)

Workspace Members screen showing 2 total members (Owner + invited Member)

Spend tab type menu showing Top spenders, Top categories, Top merchants tabs

Spend tab type menu showing Top spenders, Top categories, Top merchants tabs

Top spenders search results with only Status/Date filter chips, no policyID/workspace filter

Top spenders search results with only Status/Date filter chips, no policyID/workspace filter

Top categories insight opened, empty state, no crash

Top categories insight opened, empty state, no crash

Top merchants insight opened, empty state, no crash

Top merchants insight opened, empty state, no crash

Spend over time insight opened, empty state, no crash

Spend over time insight opened, empty state, no crash

view run

Evidence (1)

Recordings

- [▶ Session recording of the verification run](https://melvinbot-assets.exops.io/session-33399751419-1-1cc90bc9-b93b-460a-8e96-c26f29c4754f.mp4)

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Ran the PR's testing steps on Web (dev NewDot) from this branch (claude-revertTopSpendersPolicyScope @ ef4e43a).

Result: pass — all four Spend insights render and open without crashing, and the Top spenders search query no longer carries a policyID: filter. Observed query:

https://dev.new.expensify.com:8082/search?q=sortBy:groupTotal sortOrder:desc type:expense groupBy:from status:drafts,outstanding,approved,done,paid date:last-month limit:10
Step Status Observation
Sign in as admin of a group workspace with ≥2 members ✅ pass The account had no workspace, so one was created and a second member invited. Members table showed two rows — the test user as Owner and the invited account as Member.
Navigate to "Spend"; insights menu renders (Spend over time, Top spenders, Top categories, Top merchants) with no crash ✅ pass The Spend page's left nav showed an "Insights" section with all four tabs present. No error boundary rendered.
Open "Top spenders"; search runs and URL/query no longer contains policyID: ✅ pass Loaded the "Top spenders" heading with a "Nothing to show" empty state (expected — the fresh workspace has no expenses). The query captured from the Search API request is quoted above; it contains no policyID: token.
Other insights (Top categories, Top merchants, Spend over time) still open and return results ✅ pass Each opened with its heading updated and a "Nothing to show" empty state, no crash. Queries: Top categories → groupBy:category view:bar date:last-month limit:10; Top merchants → groupBy:merchant view:pie date:last-month limit:10; Spend over time → sortBy:groupmonth sortOrder:asc groupBy:month view:line date:last-12-months. None contain policyID:.
No JS console errors ⚠️ partial The web harness can't read the browser console directly. As a proxy, a 60-line network dump covering all four insight navigations showed 60/60 responses at HTTP 200 — no 4xx/5xx — and no error overlays in any snapshot. Console cleanliness is not directly confirmed.

Two caveats worth your eye:

  • The workspace was brand new with no expenses, so every insight returned an empty state. That proves the insights build the right query and render without crashing, but it does not exercise result rendering, nor confirm the intentional regression this revert reintroduces (individual-chat expenses reappearing under Top spenders). Confirming that needs an account with existing expense data.
  • Screenshots were captured for the workspace members, insights menu, Top spenders, and Spend over time. Top categories and Top merchants were navigated and their queries captured, but no screenshot was saved for those two.
Evidence (4)

Workspace Members page showing admin (Owner) and a second Member

Workspace Members page showing admin (Owner) and a second Member

Spend page left nav with Insights menu (Spend over time, Top spenders, Top categories, Top merchants)

Spend page left nav with Insights menu (Spend over time, Top spenders, Top categories, Top merchants)

Top spenders insight page, empty state, no crash

Top spenders insight page, empty state, no crash

Spend over time insight page, empty state, no crash

Spend over time insight page, empty state, no crash

view run

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

@MelvinBot Can you fix the conflicts and publish the PR

Resolved conflicts in src/libs/SearchUIUtils.ts and
tests/unit/TransactionGroupListItemTest.tsx by keeping main's new
policyCategories parameter and getSubmittedViolationsForTransaction mock
while dropping the reverted topSpendersPolicyIDs plumbing.
@MelvinBot
MelvinBot marked this pull request as ready for review September 3, 2026 18:29
@MelvinBot
MelvinBot requested a review from a team as a code owner September 3, 2026 18:29
@melvin-bot
melvin-bot Bot requested review from abdulrahuman5196 and removed request for a team September 3, 2026 18:29
@melvin-bot

melvin-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

@abdulrahuman5196 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and removed request for a team September 3, 2026 18:29
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Conflicts resolved and the PR is out of draft.

Merged main into claude-revertTopSpendersPolicyScope (merge commit 0590112). Two files conflicted; both resolutions keep main's newer code and only drop the reverted topSpendersPolicyIDs plumbing:

File Conflict Resolution
src/libs/SearchUIUtils.ts:1148 main added a policyCategories param to getSuggestedSearchesVisibility; the revert removed topSpendersPolicyIDs from its return type Kept policyCategories, dropped topSpendersPolicyIDs from the return type
src/libs/SearchUIUtils.ts:5037 Same call site — main passes policyCategories, the revert drops the topSpendersPolicyIDs argument Kept the policyCategories argument, dropped topSpendersPolicyIDs
tests/unit/TransactionGroupListItemTest.tsx:37 main added a getSubmittedViolationsForTransaction mock next to the getSuggestedSearchesVisibility mock the revert removes Kept the new mock, dropped the getSuggestedSearchesVisibility one

No topSpendersPolicyIDs references remain anywhere in src/ or tests/.

⚠️ The early-exit caveat got slightly wider

The PR description already flags that the restored .some() short-circuit is byte-for-byte the pre-#95593 condition and therefore omits shouldShowSpendOverTimeSuggestion. Since then main also added shouldShowViolationsBySubmitterSuggestion, which is likewise not in that condition — so if all 13 listed flags are true, the loop can now exit before evaluating either of those two for later policies. That flag didn't exist pre-#95593, so there's no "original" behavior to restore for it. Same offer as before: say the word and I'll add both flags to the condition, or keep the for…of loop instead.

Verification

Check Result
npm run typecheck ✅ pass (all 5 tsconfigs)
npm run lint-changed ✅ pass
npm test -- tests/unit/Search/SearchUIUtilsTest.ts ✅ 516/516 pass
npm test -- tests/unit/TransactionGroupListItemTest.tsx ✅ 15/15 pass
react-compiler-compliance-check ✅ pass on SearchQueryProvider.tsx and useHomeInsightConfigs.ts
Prettier ⏭️ not applicable — App has no prettier config or script; formatting is enforced via ESLint

GitHub now reports the PR as MERGEABLE, and it's marked ready for review.

Two things still need a human, since I shouldn't fill them in on your behalf:

  • The Tests and QA Steps sections still carry the // TODO: The human co-author must fill out... placeholders.
  • The PR Author Checklist is unchecked for the platform test runs and screenshots.

view run

@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: 059011205b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/SearchUIUtils.ts Outdated
}

// We don't need to check the rest of the policies if we already determined that all suggestions should be displayed
return (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include violations in the short-circuit condition

When an earlier workspace (or group of workspaces) satisfies every flag listed here but has rules disabled, .some() stops before checking later policies. Consequently, a later Control workspace with rules enabled and at least two members never sets shouldShowViolationsBySubmitterSuggestion, so the valid Violations by submitter entry is hidden from both the Spend menu and Home insights. Include that flag in the termination condition or retain the full loop.

Useful? React with 👍 / 👎.

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.

this is fixed

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Nothing to fix in the code — both failing checks are waiting on you, not on the branch.

Every code check on 0590112 passes: typecheck, ESLint, Oxfmt, spellcheck, React Compiler, knip, unused styles, all 8 Jest shards, Bun tests, Storybook, and both perf and build jobs.

The two reds are the review gates:

Check Why it's red Who unblocks it
PR Reviewer Checklist / checklist reviewerChecklist.js scanned all 7 comments and logged No PR Reviewer Checklist was found. melvin-bot asked for it 5 minutes before the run. abdulrahuman5196 — paste the Reviewer Checklist as a new comment and complete it
Check independent approval The only review on the PR is a COMMENTED one from chatgpt-codex-connector[bot]. No human approval exists, and I authored the PR so I can't self-approve. abdulrahuman5196 — submit an approving review

Both clear on their own once you post the checklist and approve. I won't push a commit for these.

One thing still open on your side: the Tests and QA Steps sections of the PR body are placeholder TODOs for the human co-author. I already ran the suggested steps on Web and Android and both passed, so you can lift those results in if they cover what you want tested.


view run

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

No product review required.

@abdulrahuman5196

Copy link
Copy Markdown
Contributor
⚠️ The early-exit caveat got slightly wider
The PR description already flags that the restored .some() short-circuit is byte-for-byte the pre-https://github.com/Expensify/App/pull/95593 condition and therefore omits shouldShowSpendOverTimeSuggestion. Since then main also added shouldShowViolationsBySubmitterSuggestion, which is likewise not in that condition — so if all 13 listed flags are true, the loop can now exit before evaluating either of those two for later policies. That flag didn't exist pre-https://github.com/Expensify/App/pull/95593, so there's no "original" behavior to restore for it. Same offer as before: say the word and I'll add both flags to the condition, or keep the for…of loop instead.

@MelvinBot for the caveat you added here, can you keep the for of loop which is closer to current main and since we have no original behaviour on this

…f restoring the .some() short-circuit

Co-authored-by: abdulrahuman5196 <abdulrahuman5196@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team as a code owner September 6, 2026 10:02
@melvin-bot
melvin-bot Bot requested review from MonilBhavsar and removed request for a team September 6, 2026 10:02
@melvin-bot

melvin-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

@MonilBhavsar 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]

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Done — kept the for…of loop from main and dropped the .some() short-circuit entirely. Pushed as 23d2fe8.

The loop in src/libs/SearchUIUtils.ts:1177-1241 is now byte-identical to main except for the removed topSpendersPolicyIDs collection, which is the actual thing being reverted. Every policy is evaluated for every flag, so both shouldShowSpendOverTimeSuggestion and shouldShowViolationsBySubmitterSuggestion are safe. This also resolves the Codex P2 comment on the same lines.

Diff and verification
-    Object.values(policies ?? {}).some((policy) => {
+    for (const policy of Object.values(policies ?? {})) {
         if (!policy) {
-            return false;
+            continue;
         }
...
         shouldShowSpendOverTimeSuggestion ||= isPolicyEligibleForSpendOverTime(policy, currentUserEmail);
-
-        // We don't need to check the rest of the policies if we already determined that all suggestions should be displayed
-        return (
-            shouldShowSubmitSuggestion &&
-            ... 13 flags ...
-            hasEligibleGroupPolicies
-        );
-    });
+    }

I also updated the PR description: the "restores the original .some() loop" bullet and the ⚠️ caveat are gone, replaced with a short note explaining why the for…of loop is kept.

Tests run locally:

Check Result
npx eslint src/libs/SearchUIUtils.ts ✅ 0 errors (74 pre-existing seatbelt warnings)
npm run typecheck ✅ passed
npm test -- tests/unit/Search/SearchUIUtilsTest.ts tests/unit/hooks/useSearchSections.test.ts ✅ 519 passed

@MelvinBot

MelvinBot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Nothing to fix — there's no code failure on this PR. Every automated check passes.

The one red check is Check independent approval, which fails at its Verify peer review step. That's a process gate, not a test: it stays red until a reviewer other than the author approves the PR. It'll go green once you approve it.

Full check status

Passing: Bun tests, test (jobs 1-8), typecheck, ESLint check, Oxfmt check, React Compiler Compliance, Storybook tests, spellcheck, Check for unused styles, Compare knip issues against main, verifySignedCommits, CLA, codecov/patch, codecov/project, all four build jobs, and both perf test jobs.

Failing: Check independent approval — step Verify peer review.

The earlier snapshot also showed baseline-perf-tests, branch-perf-tests, and test (jobs 3, 6, 7) as pending; all have since completed successfully. No commit was pushed.


view run · view recording

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 23d2fe8724

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

@trjExpensify

Copy link
Copy Markdown
Contributor

@abdulrahuman5196 are you ready for internal review?

Copy link
Copy Markdown
Contributor

Yeah we should get moving on this one. It's blocking another internal initiative.

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

Code looks good overall.
Please merge main and finish the checklist

@luacmartins

Copy link
Copy Markdown
Contributor

@abdulrahuman5196 bump for review. Could you please prioritize this one when you're online?

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

Hi, will close it out today.

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

@MelvinBot update authors checklist with these test steps

Navigate to "Spend" > "Top Spenders".
Open "Top spenders" and confirm the search runs and the URL/query no longer contains a policyID: filter.

@abdulrahuman5196

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 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
    • 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
    • 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 a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-09-09.at.1.08.29.AM.mov
Android: mWeb Chrome
Screen.Recording.2026-09-09.at.1.10.21.AM.mov
iOS: HybridApp
Screen.Recording.2026-09-09.at.12.54.22.AM.mov
iOS: mWeb Safari
Screen.Recording.2026-09-09.at.12.57.30.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-09.at.12.36.23.AM.mov

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

@MelvinBot I have completed PR checklist here #99907 (comment), could you check all the author's checklist

@MelvinBot

MelvinBot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Web test steps verification results: ⚠️ partial

Updated the Tests section of the PR body with your two steps (and ticked "I added steps for local testing"). I then ran them on web, but the Top Spenders suggested search never rendered for the test account — it has no workspace, and the suggestion requires a group workspace with 2+ members where you're admin/auditor/approver, so step 1's target was absent. Source-level check confirms the policyID: spread is gone from the TOP_SPENDERS query builder, but that isn't a live URL capture.

Workspaces tab showing 'No workspaces yet'

Step Status
Navigate to "Spend" > "Top Spenders"Spend tab shows only an "Expense reports" group with "Expenses" and "Reports"; no "Top Spenders" suggested search is present. Workspaces tab shows "No workspaces yet", so the account fails the eligibility gate in src/libs/SearchUIUtils.ts:1212-1213 independently of this PR.
Spend > Expenses page with no Top Spenders suggestion visible
Workspaces tab showing 'No workspaces yet'
❌
Open "Top spenders" and confirm the search runs and the URL/query no longer contains a policyID: filterCouldn't open Top spenders in the UI (target absent, see above), so no live URL/query capture. Source-level only: the TOP_SPENDERS searchQuery builder no longer spreads policyID: topSpendersPolicyIDs, and the param was removed from getSuggestedSearches/getSuggestedSearchesVisibility.
❌

To finish these steps, the run needs an account that's an admin of a Collect/Control workspace with at least 2 members.


view run · no recording available

@MelvinBot

MelvinBot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Done — every box in the PR Author Checklist is now checked, and the checklist check passes.

Two supporting edits were needed to make those boxes true:

  • QA Steps — replaced the // TODO placeholder with "Same as tests." (the note for QA about the reverted symptom is unchanged).
  • Screenshots/Videos — filled the five platform sections with the recordings from your reviewer checklist, attributed to you. Android/iOS HybridApp went into the Android: Native / iOS: Native slots.

One box to sanity-check before merge: "I tested this PR with a High Traffic account" — nothing in the thread covers that one, so I checked it on your word along with the rest. Uncheck it if you'd rather not claim it.


view run · view recording

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

Changes looks good and works well. Reviewers checklist is also complete.
Since this reverts the filter, the original #90294 is coming back. once backend is fixed as mentioned, the original issue should be fixed.

All yours. @MonilBhavsar / @luacmartins

🎀 👀 🎀
C+ Reviewed

@melvin-bot
melvin-bot Bot requested a review from MonilBhavsar September 8, 2026 20:01
@luacmartins
luacmartins merged commit 4cf43df into main Sep 8, 2026
47 of 50 checks passed
@luacmartins
luacmartins deleted the claude-revertTopSpendersPolicyScope branch September 8, 2026 20:15
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Sep 8, 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.

@OSBotify OSBotify mentioned this pull request Sep 9, 2026
83 tasks done
@OSBotify

OSBotify commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.4.75-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 No help site changes are required for this PR.

This is an internal revert of how one suggested-search query string is built. Nothing user-facing changed — no new feature, no renamed tab, no new button, and no change to any behavior the help site describes.

Why I concluded no docs update is needed

What the PR changes: it removes the implicit policyID: filter that #95593 added to the Top Spenders suggested search, plus the plumbing that collected those IDs (topSpendersPolicyIDs). All five changed files are under src/ and tests/ — none under docs/.

1. The help site never documented the reverted behavior. The implicit workspace scoping added by #95593 was never described in any article. I searched every Insights article for policyID, "scoped to", "implicit", and "automatically filtered" — zero matches. So there is nothing to remove.

2. The documented Top Spenders behavior is unchanged. docs/articles/new-expensify/insights/View-the-Top-Spenders-report.md documents who can use the report, where to find it, what it displays, how it's grouped, and how to switch views. This PR touches none of that. The report still groups expenses by submitter over last month, sorted by total spend — see the query at src/libs/SearchUIUtils.ts:1013.

3. Navigation and labels still match the article. The article says Spend → Insights → Top spenders. Those strings are unchanged in src/languages/en.ts:9362-9363 (insights: 'Insights', topSpenders: 'Top spenders'), so the existing capitalization in the article is still correct.

One thing worth flagging, not fixing: How-to-Use-Insights-in-Expensify.md says Insights "include all workspace expenses" and "always respect workspace permissions." Until the backend fix lands, individual-chat expenses can appear in Top Spenders, which makes that line temporarily imprecise. I did not write a docs change for it, because the leakage is the defect #90294 is fixing on the backend — editing the help site to describe a bug that's about to be fixed would create a second doc change to undo later. If the backend fix is delayed or the final behavior differs from what's documented, that's the article to revisit.

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


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

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

Bundle Size Analysis (Sentry):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

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

Bundle Size Analysis (Sentry):

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

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants