Skip to content

[Insights: Violations][R3] Add the violation filter - #105466

Merged
neil-marcellini merged 27 commits into
Expensify:mainfrom
nkdengineer:fix/105301
Nov 16, 2026
Merged

neil-marcellini merged 27 commits into
Expensify:mainfrom
nkdengineer:fix/105301

Conversation

@nkdengineer

@nkdengineer nkdengineer commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

[Insights: Violations][R3] Add the violation filter

Fixed Issues

$ #105301
PROPOSAL:

Tests

Precondition: Has at least a WS-enabled rules feature and has some submitted expense with violation

  1. Go Spend > Filter
  2. Verify that Violation filter appears
  3. Select any violation
  4. Verify that the expenses that contain the selected violations appear
  5. Select negative filter
  6. Verify that the expenses without selected violations appear
  7. Open search router
  8. Type violation:/-violation:, verify that the violation name option appears
  9. Select any violation
  10. Verify that the result the same as above.
  • 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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-10-30.at.14.38.18.mov
Android: mWeb Chrome
Screen.Recording.2026-10-30.at.14.39.37.mov
iOS: Native
Screen.Recording.2026-10-30.at.14.40.42.mov
iOS: mWeb Safari
Screen.Recording.2026-10-30.at.14.35.35.mov
MacOS: Chrome / Safari
Screen.Recording.2026-10-30.at.14.49.09.mov

@melvin-bot

melvin-bot Bot commented Oct 30, 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

@github-actions

Copy link
Copy Markdown
Contributor

It looks like this PR adds a search filter or column. Please double check the following:

  • The filter is available in the Search filters dropdown and returns the expected results.
  • The filter has a matching column that can be shown through Display > Edit columns.
  • The column can be sorted by clicking its header.
  • Export > Current view includes the column in the exported CSV.

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/CONST/SENTRY_LABEL.ts 100.00% <ø> (ø)
src/CONST/index.ts 96.15% <ø> (ø)
.../components/CategoryPicker/CategoryPickerModal.tsx 93.33% <ø> (ø)
...nents/Search/SearchRouter/buildSubstitutionsMap.ts 100.00% <100.00%> (ø)
src/hooks/useAdvancedSearchFilters.ts 97.95% <100.00%> (+0.08%) ⬆️
src/hooks/useAutocompleteSuggestions.ts 71.88% <100.00%> (+1.29%) ⬆️
src/libs/PolicyUtils/features.ts 88.88% <100.00%> (ø)
src/libs/SearchParser/autocompleteParser.js 61.86% <ø> (+0.20%) ⬆️
src/libs/SearchParser/searchParser.js 86.46% <ø> (+0.08%) ⬆️
...s/workspace/members/WorkspaceMemberDetailsPage.tsx 85.67% <ø> (ø)
... and 6 more
... and 8 files with indirect coverage changes

@nkdengineer

Copy link
Copy Markdown
Contributor Author

@codex review.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T17:48:01.119885Z a6e10b8 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 2c1a2a2768

ℹ️ 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 Resolved
Comment thread src/libs/SearchQueryUtils.ts Resolved
Comment thread src/hooks/useAdvancedSearchFilters.ts Resolved
@nkdengineer
nkdengineer marked this pull request as ready for review November 2, 2026 17:27
@nkdengineer
nkdengineer requested review from a team as code owners November 2, 2026 17:27
@melvin-bot
melvin-bot Bot requested review from dylanexpensify and gijoe0295 and removed request for a team November 2, 2026 17:27
@melvin-bot

melvin-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

@gijoe0295 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 November 2, 2026 17:27
Comment thread src/hooks/useAdvancedSearchFilters.ts Resolved

@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: a6e10b83f9

ℹ️ 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/hooks/useAutocompleteSuggestions.ts Resolved
@dylanexpensify
dylanexpensify requested review from JmillsExpensify and removed request for dylanexpensify November 3, 2026 10:20
@gijoe0295

gijoe0295 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Bug: A removed "Is not" value stays in the query (narrow layout only)

  1. On mWeb, in the search router, submit type:expense -violation:overLimit
  2. Open the advanced Filters page
  3. Tap the Violation row. The picker opens "Is not" with "Over limit" selected
  4. Tap "Is", uncheck "Over limit", check any other violation, then tap Confirm
  5. Tap Apply filters
  6. The -violation:overLimit filter stays ❌ It should be cleared
Screen.Recording.2026-11-03.at.23.08.38.mov

@gijoe0295

gijoe0295 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Needs improvement: Duplicate violation short names

  • cashExpenseWithNoReceipt and receiptRequired both read as "Receipt required"
  • customRules and ruleViolation both read as "Custom rule violation"

Selecting these violations together show duplicate values in the filter chip like this:

Screenshot 2026-11-03 at 23 17 39

And in autocomplete suggestions too:

Screenshot 2026-11-03 at 23 22 08

This is not really a blocker but more of an improvement over existing violation names.

@gijoe0295

gijoe0295 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Also should we display the search input for Violation filter list here? We have 46 options to scroll through.

Screenshot 2026-11-03 at 23 19 33

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

Left some findings above

Comment thread src/libs/SearchUIUtils.ts Resolved
@neil-marcellini

Copy link
Copy Markdown
Contributor

Maybe we name this for the user with something like "Category differs from default"? @trjExpensify does that sound good?

@trjExpensify

Copy link
Copy Markdown
Contributor

Yeah, I think for both of these we need to use a message for the rule that was violated otherwise they're really quite pointless for insights. CC: @luacmartins @JS00001

@trjExpensify

Copy link
Copy Markdown
Contributor

I just asked @JS00001 about these two as they are related to the new rules engine in active development. I think we should exclude them from the list for now.

  1. customRules is being refactored to nonDefaultX in this PR. When those land, they should appear in the violations filter more aptly named.
  2. ruleViolation exists, but no customer can hit it yet because we haven't migrated any "flagging" to the new rules engine. When we do, we can bring back more aptly named violations for whatever those are.

@nkdengineer

Copy link
Copy Markdown
Contributor Author

Why are we using an exclamation mark and not a flag icon like the doc spec? CC: @dubielzyk-expensify

I didn't know we had a design doc for this. @neil-marcellini Can you please share the doc for my email nkdengineer@outlook.com

@nkdengineer

Copy link
Copy Markdown
Contributor Author

@neil-marcellini I just realized that we can still have some violations like Missing category even if we don't enable the rule feature. Should we always display this filter and skip the rule-enable check?

@neil-marcellini

Copy link
Copy Markdown
Contributor

@neil-marcellini I just realized that we can still have some violations like Missing category even if we don't enable the rule feature. Should we always display this filter and skip the rule-enable check?

For now, let's keep the rule-enabled check in place, since that's what Tom and I planned. I think it's okay if there are still live missing category violations, but you can filter expenses by this. At the same time, I'm also okay with getting rid of the check. I don't think it needs to be a blocker. What do you think @trjExpensify?

@nkdengineer

Copy link
Copy Markdown
Contributor Author

@neil-marcellini If so it's ready for review again.

@nkdengineer

Copy link
Copy Markdown
Contributor Author

Let me know if we need to do this @neil-marcellini

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

(Neil's AI agent, human reviewed)

Thanks, everything from my last review is done. One change left (inline comment below).

Comment thread src/libs/SearchQueryUtils.ts Resolved
@nkdengineer

Copy link
Copy Markdown
Contributor Author

@neil-marcellini I've updated.

@melvin-bot
melvin-bot Bot requested a review from neil-marcellini November 16, 2026 05:19
@neil-marcellini

Copy link
Copy Markdown
Contributor

(Neil's AI agent)

I tested this PR on web (Chrome) in Neil's local dev environment at 0d851e1. All test steps pass.

Setup: a new Control workspace with Rules on ($50 max expense amount, 30-day max age), and one submitted report with 4 expenses:

Expense Violation
Overlimit Hotel, $100 Over limit
Old Taxi, $30, Sep 1 Date older than max expense age
Clean Lunch, $10 none
No Category Cafe, $20 none

Baseline: 4 submitted expenses

Filters (steps 1-6)

1-2. The Violation filter appears. Custom rule violation, Rule violation, and the cash expense notice are not in the list, as intended.
Violation filter options

3-4. is Over limit returns only Overlimit Hotel.
Violation is Over limit

Selecting both violations returns both violating expenses.
Violation is Over limit or Date older than max expense age

5-6. is not with both selected returns only the two clean expenses.
Violation is not Over limit or Date older than max expense age

Search router (steps 7-10)

violation: suggests the violation names.
violation: suggestions

violation:"Over limit" gives the same result as the filter.
violation:Over limit results

-violation: suggests the same names, and -violation:"Over limit" returns the other three expenses.
-violation: suggestions
-violation:Over limit results

Notes

  • Suggestions disappear once the typed value contains a space, e.g. violation:Over l. category:Meals a behaves the same way, so this already happens on main and isn't caused by this PR.
  • The JS console shows no errors from this feature. The only ones are dev-only React warnings about the dataElement, dataSourceFile and dataComponent props, plus a textDecoration style warning. Neither comes from this PR.

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

Looks great, thank you. Next time, please make sure you update the test videos. I had Claude do the testing for you, but it did take a while.

@neil-marcellini
neil-marcellini merged commit 31dfa3f into Expensify:main Nov 16, 2026
40 of 42 checks passed
@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.

@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

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

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

@github-actions

Copy link
Copy Markdown
Contributor

@MelvinBot

MelvinBot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Help site update needed — this adds a new, non-beta violation filter, warranting one row in the existing expense search operators table.

No docs PR created: required live UI verification was blocked because the test account lacked Rules-enabled expenses, so labels and filtering behavior could not be confirmed.


view run · view recording

@trjExpensify

Copy link
Copy Markdown
Contributor

@neil-marcellini I just realized that we can still have some violations like Missing category even if we don't enable the rule feature. Should we always display this filter and skip the rule-enable check?

For now, let's keep the rule-enabled check in place, since that's what Tom and I planned. I think it's okay if there are still live missing category violations, but you can filter expenses by this. At the same time, I'm also okay with getting rid of the check. I don't think it needs to be a blocker. What do you think @trjExpensify?

Agree it doesn't need to be a blocker. Weird though.. if Rules is disabled, why are we still flagging categories as required on the workspace? @JmillsExpensify @JS00001 @luacmartins @Krishna2323 that seems like a rules revamp bug. The setting was moved inside the Rules page, it's the only place configurable, so if that feature OR categories is disabled, so should the required categories setting right?

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.

8 participants