Skip to content

[NoQA][Insights] Add Compliance charts and chart eligibility rules - #105266

Merged
luacmartins merged 29 commits into
Expensify:mainfrom
software-mansion-labs:@OlGierd03/Insights-Compliance-Charts
Nov 9, 2026
Merged

luacmartins merged 29 commits into
Expensify:mainfrom
software-mansion-labs:@OlGierd03/Insights-Compliance-Charts

Conversation

@OlGierd03

@OlGierd03 OlGierd03 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Adds the Compliance dashboard charts: Violations over time, Top violations, Violations by submitter and Violations by approver. All of them count expenses (metric: COUNT). Top violations groups by violation type through a new GROUP_BY.VIOLATION, which only Insights uses and Search autocomplete hides. Search can't filter by violation type yet, so its "View on Spend" opens a flat list of all violations. The submitter and approver charts narrow to their own stage (has:submitted-violation / has:approved-violation) and its date (submitted: / anyApproval:), so the drill-in matches what the chart counts. Violations by submitter needs a workspace with at least two members, and Violations by approver also needs approvals enabled. Eligibility only counts workspaces where the user is an admin or auditor, and the Compliance workspace filter lists only those.

Known issues on Compliance:

Warning

The data includes workspaces where the user isn't an admin or auditor.

Will be fixed on the backend by limiting Compliance data to admin/auditor workspaces.

Warning

GetInsights returns each group as value instead of accountID / violation

normalizeInsightsSnapshot temporarily renames it to let the charts reuse the Search grouping code. Will be fixed on the backend by returning the named fields, after which normalizeInsightsSnapshot can be dropped.

Warning

The drill-in from Violations over time and Top violations can show a different number of expenses than the chart.

The Insights numbers are correct, only the Spend query can't express the same filter yet. Will be fixed by the Submitters/Approvers selector in #697879.

Warning

Clicking a Top violations slice opens all violations, not only the clicked type.

Will be fixed by the violation: filter in Search in #105301.

Warning

"View on Spend" from Top violations opens a flat list of expenses, not grouped by violation type.

Will be fixed by group-by:violation in Search in #105303, backed by #697165 on the backend.

Fixed Issues

$ #102809

Tests

Precondition: account with the insightsCompliance beta that is an admin of a workspace with at least two members and approvals enabled, and a regular member of another workspace. In the admin workspace, some expenses with violations are submitted and approved in the current month.

  1. Open Insights, switch to Compliance and verify Violations over time, Top violations, Violations by submitter and Violations by approver show counts of expenses.
  2. Verify Top violations shows violation names (e.g. "Description required") and Violations by submitter / approver show member names with avatars.
  3. Click a bar in Violations by submitter and verify Spend opens with from:, has:submitted-violation and a submitted: date that match the chart's count.
  4. Go back, click a bar in Violations by approver and verify Spend opens with approver:, has:approved-violation and an anyApproval: date that match the chart's count.
  5. Go back, click a slice in Top violations and verify Spend opens as a list of expenses with violations, sorted by date.
  6. Open the workspace filter and verify it lists only the workspace you're an admin of.
  7. Disable approvals in the workspace and verify Violations by approver disappears.
  8. In a workspace with only one member, verify Violations by submitter and Violations by approver are hidden.
  9. Switch to Spend and verify its charts and workspace filter are unchanged.

Offline tests

  1. Open Compliance, then go offline.
  2. Change the workspace or date filter and verify the charts keep the last loaded data and no error shows.
  3. Go online and verify the charts reload for the new filters.

QA Steps

NoQA

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 verified any copy / text that was added to the app 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 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 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

MacOS: Chrome / Safari

@melvin-bot

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

github-actions Bot commented Nov 3, 2026

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.

Comment thread src/pages/Insights/insightsAccess.ts Resolved
Comment thread src/pages/Insights/insightsAccess.ts Resolved
Comment thread tests/unit/insightsQueriesTest.ts Resolved
@OlGierd03
OlGierd03 marked this pull request as ready for review November 4, 2026 20:40
@OlGierd03
OlGierd03 requested review from a team as code owners November 4, 2026 20:40
@melvin-bot
melvin-bot Bot requested review from aldo-expensify, cristipaval, daledah and trjExpensify and removed request for a team November 4, 2026 20:40
luacmartins
luacmartins previously approved these changes Nov 9, 2026
@luacmartins

Copy link
Copy Markdown
Contributor

@OlGierd03 conflicts

@OlGierd03

Copy link
Copy Markdown
Contributor Author

Resolving! 🏃

@OlGierd03

Copy link
Copy Markdown
Contributor Author

@luacmartins Should be good to go now

luacmartins
luacmartins previously approved these changes Nov 9, 2026
@luacmartins

luacmartins commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

lol thanks GH

Workflows are being blocked due to a scheduled brownout of the default `pull_request_target` protection for affected public repositories. This window ends at November 9, 2026 at 18:00:00 UTC. If you need these workflows to run, ask an administrator to explicitly allow `pull_request_target` in an applicable Actions event policy. See https://gh.io/securely-using-pull_request_target#default-policy-for-pull_request_target for guidance.

@OlGierd03

Copy link
Copy Markdown
Contributor Author

👀 Some more conflicts 💥🥊

@luacmartins

Copy link
Copy Markdown
Contributor

@OlGierd03 the GH brownout got the last job stuck and I can't re-run it. Can you push another commit to the PR to re-trigger the workflow please?

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Going to test this real quick.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

This comment has been minimized.

@JmillsExpensify

Copy link
Copy Markdown
Contributor

All looks good to me!

@mhawryluk

Copy link
Copy Markdown
Member

@luacmartins all set

@luacmartins
luacmartins merged commit 9920e71 into Expensify:main Nov 9, 2026
37 checks passed
@OSBotify

OSBotify commented Nov 9, 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.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@OSBotify OSBotify mentioned this pull request Nov 9, 2026
72 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

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

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

@MelvinBot

Copy link
Copy Markdown
Contributor

FullStory updates are recommended: stable custom elements for Compliance charts and menu actions, plus masking employee identities in tables and tooltips. No new events, user properties, or page-view code are needed.

Created Update FullStory for E/A#105266 Compliance charts and eligible workspace filtering, assigned to OlGierd03, with Weekly and then AutoAssignerProductTeam added separately.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.35-3 🚀

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