Skip to content

[Insights: Violations]: Expanding group & Suggested search v2 - #98391

Merged
neil-marcellini merged 16 commits into
Expensify:mainfrom
nkdengineer:revert-98345-revert-97067-fix/95859
Sep 1, 2026
Merged

neil-marcellini merged 16 commits into
Expensify:mainfrom
nkdengineer:revert-98345-revert-97067-fix/95859

Conversation

@nkdengineer

@nkdengineer nkdengineer commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Re-implement Expanding group & Suggested search for Violations and fix regression

Fixed Issues

$ #95859
#98204
#98244
PROPOSAL:

Tests

  • Suggested search
  1. Create a control workspace
  2. Enable rules
  3. Add a member
  4. Submit some expenses with various violations as the workspace owner and the member, with more expenses coming from the member
  5. Submit some expenses without violations
  6. As the workspace owner, open the Spend page
  7. Verify there is a suggested search under the Insights section called “Violations by submitter”, and it has the icon with a person and an eye
  8. Click on it
  9. Verify you see a table with columns From, Expenses, and Total
  10. Verify there is a down arrow next to Expenses meaning it is sorted by count of expenses descending
  11. Verify the count and total is correct for each user
  12. Verify the filters display “Date: Last month”
  13. Run the same test as an auditor
  • Expanding group
  1. Run the same setup as the manual tests for the section above
  2. Ensure one expense has multiple violations
  3. Click on a row for one user
  4. Verify it expands, shows a brief loader, and then displays a table of expenses for that user
  5. Verify the proper expenses are displayed
  6. Verify there is a Violations column and it contains the proper violation names, separated by commas for multiple violations
  1. Go to Spend > Violations by submitter.
  2. Click Has filter.
  3. Deselect Submitted violation.
  4. Select any other filter except Submitted violation.
  5. Click Apply.
  6. Verify that Violations by submitter is not highlighted
  1. Go to Spend > Violations by submitter.
  2. Click Submitted and change it to This month.
  3. Expand the group.
  4. Click Display > Edit columns.
  5. Verify that the Violations option appears
  • Verify that no errors appear in the JS console

Offline tests

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
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2026-07-27.at.14.32.35.mov
Android: mWeb Chrome
Screen.Recording.2026-07-27.at.14.25.08.mov
iOS: Native
Screen.Recording.2026-07-27.at.14.29.43.mov
iOS: mWeb Safari
Screen.Recording.2026-07-27.at.14.27.52.mov
MacOS: Chrome / Safari
Screen.Recording.2026-07-27.at.14.20.06.mov

@melvin-bot

melvin-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@codecov

codecov Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/CONST/index.ts 91.07% <ø> (ø)
...archList/ListItem/TransactionGroupListExpanded.tsx 68.18% <100.00%> (ø)
.../TransactionListItem/TransactionListItemNarrow.tsx 0.00% <ø> (ø)
...em/TransactionListItem/TransactionListItemWide.tsx 0.00% <ø> (ø)
src/components/Search/SearchTableHeader.tsx 49.43% <ø> (ø)
...ents/TransactionItemRow/TransactionItemRowWide.tsx 98.38% <100.00%> (+0.01%) ⬆️
src/hooks/useSearchBulkActions.ts 71.15% <100.00%> (+0.04%) ⬆️
src/hooks/useSearchShouldCalculateTotals.ts 100.00% <ø> (ø)
src/hooks/useSearchTypeMenuSections.ts 98.38% <100.00%> (+0.02%) ⬆️
src/libs/ReportActionsUtils.ts 80.41% <ø> (+0.08%) ⬆️
... and 5 more
... and 25 files with indirect coverage changes

@melvin-bot

melvin-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx bun ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx bun ./scripts/generateTranslations.ts --compare-ref main

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

App/src/libs/SearchUIUtils.ts

Lines 1068 to 1070 in 71d8fb2

groupBy: CONST.SEARCH.GROUP_BY.FROM,
submittedOn: CONST.SEARCH.DATE_PRESETS.LAST_MONTH,
has: [CONST.SEARCH.HAS_VALUES.SUBMITTED_VIOLATION],

P2 Badge Include violations in grouped CSV exports

When a user opens this suggested search and exports it without first saving custom columns, the query has groupBy:from but no columns. The grouped branch in useSearchBulkActions.ts:892-896 then bypasses getColumnsToShow() and exports only TYPE_DEFAULT_COLUMNS.EXPENSE, which excludes the new Violations column, even though expanded rows display it. Include Violations in this search's default columns or account for the submitted-violation filter in the grouped export path.


const isEligibleForViolationsBySubmitterSuggestion = isGroupPolicyEligible && (isAdmin || isAuditor) && arePolicyRulesEnabled(policy) && memberCount >= 2;

P2 Badge Preserve insights for migrated Control workspaces

For migrated Control workspaces where areRulesEnabled is undefined, arePolicyRulesEnabled() only reports rules as enabled when it receives the policy categories containing legacy category rules (PolicyUtils.ts:1684-1688). This visibility calculation passes only the mapped policy and has no category data, so eligible admins and auditors on those workspaces never see the Violations by submitter insight. Supply the relevant categories or otherwise preserve the helper's legacy-Control fallback.

ℹ️ 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
@dubielzyk-expensify

Copy link
Copy Markdown
Contributor

Let us know when this is ready for design testing :)

@nkdengineer

Copy link
Copy Markdown
Contributor Author

Let us know when this is ready for design testing :)

@dubielzyk-expensify It's ready now.

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

This comment has been minimized.

@dubielzyk-expensify

Copy link
Copy Markdown
Contributor

Might need @trjExpensify and @shawnborton to test this. Videos look good though

@shawnborton

Copy link
Copy Markdown
Contributor

Generally tests well to me. Though question for @trjExpensify - when do we decide to show the red violation text under the row vs only showing it in the Violations column? I see a mixed bag:
CleanShot 2026-08-20 at 08 31 46@2x

@nkdengineer

Copy link
Copy Markdown
Contributor Author

@cretadn22 Please review the version 2 here.

@trjExpensify

Copy link
Copy Markdown
Contributor

Though question for @trjExpensify - when do we decide to show the red violation text under the row vs only showing it in the Violations column? I see a mixed bag:

Yeah, the RBR violations are live violations that are still present on the expense (i.e haven't been fixed).

The column of violations are the violations that were present at either the time of submission or approval (stored in those actions accordingly). Violations reporting doesn't let a submitter get away with submitting a bunch of expenses with violations, wasting approvers time and holding up the close, but eventually fixing them so they "go away". Similarly for an approver, if they approve a bunch of expenses with violations, that the finance team eventually fix, that's all still captured in violations reporting.

@trjExpensify

Copy link
Copy Markdown
Contributor

#97067 (comment) per here, the "Expense too old" is still present on this adhoc build, when it should be "Date older than max expense age".

Similarly, we're still showing "Itemised receipt required" AND "receipt required" at the same time. We don't duplicate this violation to the submitter, so we shouldn't do it here either.

image

@trjExpensify

Copy link
Copy Markdown
Contributor

Also, @neil-marcellini where is the Violations filter? (Ref). Should I be seeing it in this PR?

@trjExpensify

Copy link
Copy Markdown
Contributor

Also worth noting that I see Submitted violation as an option in the has: filter when I don't even have a workspace, let alone Rules enabled.

@nkdengineer

Copy link
Copy Markdown
Contributor Author

@cretadn22 Please review again.

Comment thread src/components/TransactionItemRow/TransactionItemRowWide.tsx Outdated
Comment thread src/libs/SearchQueryUtils.ts
@cretadn22

Copy link
Copy Markdown
Contributor

@nkdengineer Testing went smoothly overall. No new bugs were found, just a few issues pointed above

@nkdengineer

Copy link
Copy Markdown
Contributor Author

@cretadn22 Updated your comment.

@melvin-bot
melvin-bot Bot requested a review from neil-marcellini September 1, 2026 17:33

@neil-marcellini neil-marcellini 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.

Updates look good. Thanks!

@neil-marcellini
neil-marcellini merged commit 4fea359 into Expensify:main Sep 1, 2026
36 of 38 checks passed
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify OSBotify mentioned this pull request Sep 2, 2026
82 tasks done
@OSBotify

OSBotify commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.4.66-0 🚀

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

@mitarachim

Copy link
Copy Markdown

Deploy Blocker #100114 was identified to be related to this PR.

@mitarachim

Copy link
Copy Markdown

Deploy Blocker #100122 was identified to be related to this PR.

@mitarachim

Copy link
Copy Markdown

Deploy Blocker #100139 was identified to be related to this PR.

@OSBotify

OSBotify commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.4.68-0 🚀

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

@OSBotify

OSBotify commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 9.4.68-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants