Skip to content

[NoQA] [Insights] Render the Spend dashboard - #101218

Merged
luacmartins merged 17 commits into
Expensify:mainfrom
software-mansion-labs:insights/render-spend-dashboard
Sep 22, 2026
Merged

luacmartins merged 17 commits into
Expensify:mainfrom
software-mansion-labs:insights/render-spend-dashboard

Conversation

@mhawryluk

@mhawryluk mhawryluk commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Explanation of Change

Renders the dashboard fetched via the getInsights action in the Insights page. A headline chart above a grid of supporting ones, each card getting its rows and state from the snapshot the onyx record names for it.

Doesn't include the design's inline tables and horizontal bar charts, as PRs for those are still in review, so they will be added later.

InsightsDashboard moves into its own file and resolves the page state from that record. dashboardSpecs gains each chart's title, view and color, plus an isPolicyEligible rule where a chart has one. Top spenders is the only one, so isPolicyEligibleForTopSpenders is lifted out of the Spend page's suggested-search visibility and shared. Some chart/widget-related elements become shared rather than copied: row derivation into useGroupedItems, drill-down query building into chartDrillDown.ts, WidgetHeaderMenu into src/components, and chart errors/empty state components.

The page has two different empty states: InsightsNoExpensesState when the record says the account has no expenses at all, with a "Create expense" button, and InsightsEmptyState when it has expenses but none fall inside the filters.

BarChart takes a color?: string prop, so a chart names the color it is drawn in rather than choosing between the palette and one fixed default. Left out, each bar still takes its color from the palette by rank. getMemberSections takes an optional onyxPersonalDetailsList, used when the snapshot carries no details for a member, cause the personal details are not send in the snapshots' data by the GetInsight command.

Fixed Issues

$ #100652
$ #100654
PROPOSAL: N/A

Tests

  1. Enable the insightsPage beta.
  2. Open the Insights tab.
  3. Verify the graphs show as loading (per graph spinners) while we fetch data and there's no data fetched already.
  4. Verify the dashboard renders graphs when the data arrives from the backend.
  5. Verify there are 4* charts: Spend over time, Top merchants, Top spenders*, Top categories and that they look correct.
  6. Verify the chart shows data for the default filters: year-to-date, all workspaces, default workspace's currency, group-by: month (for Spend over time).
  7. Verify there is no Top spenders chart when the user is not an admin/approver/auditor of any workspace or that workspace has only one member.
  8. Verify clicking on a point/bar/slice on a chart navigates to Spend and shows a table of expenses for that clicked group.
  9. Click on the three dot menu on the insights widget and click "View on Spend".
  10. Verify we're navigated to the Spend tab and we show groups of that particular chart, but in a table view and with no limit of the number of rows.
  11. Simulate failing network in troubleshoot, verify there is an error message on the insights page and clicking the retry button refetches the backend query.
  12. Log in to an account that has no expenses at all. Verify there is a dedicated empty state in the Insights page with a CTA button for creating an expense.
  13. Create an expense, but set its date to last year. Verify there is a different empty state on the Insights page with no CTA button.

Offline tests

  1. Clear cache and then go offline.
  2. Open the insights page.
  3. Verify there is a full page offline message.
  4. Go back online. Verify the data is fetched and the graphs show up.
  5. Go back offline again.
  6. Verify we're still showing the previously fetched graphs and there's an offline indicator at the bottom of the page.

QA Steps

No tests.

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
Android: mWeb Chrome
iOS: Native
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-09-21.at.12.19.15.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Nagranie.z.ekranu.2026-09-21.o.12.10.13.mov
Nagranie.z.ekranu.2026-09-21.o.11.08.54.mov
Nagranie.z.ekranu.2026-09-21.o.12.11.34.mov
Nagranie.z.ekranu.2026-09-21.o.12.16.35.mov

@melvin-bot

melvin-bot Bot commented Sep 15, 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

@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/components/Charts/PieChart/PieChartContent.tsx 0.00% <ø> (ø)
src/components/Icon/chunks/illustrations.chunk.ts 0.00% <ø> (ø)
src/components/WidgetHeaderMenu.tsx 100.00% <ø> (ø)
src/libs/SearchUIUtils.ts 71.18% <100.00%> (+0.02%) ⬆️
src/pages/Insights/InsightsPage.tsx 0.00% <ø> (ø)
src/pages/Insights/dashboardSpecs.ts 100.00% <ø> (ø)
src/pages/Insights/insightsQueries.ts 95.00% <100.00%> (+0.26%) ⬆️
src/pages/Insights/resolveChartData.ts 100.00% <100.00%> (ø)
src/pages/Insights/resolveDashboardState.ts 100.00% <100.00%> (ø)
src/pages/home/RecentlyAddedSection/index.tsx 100.00% <ø> (ø)
... and 18 more
... and 56 files with indirect coverage changes

@OSBotify

Copy link
Copy Markdown
Contributor

🦜 Polyglot Parrot! 🦜

Squawk! Looks like you added some shiny new English strings. Allow me to parrot them back to you in other tongues:

View the translation diff
diff --git a/src/languages/de.ts b/src/languages/de.ts
index 683d254e..8d215b17 100644
--- a/src/languages/de.ts
+++ b/src/languages/de.ts
@@ -1167,7 +1167,9 @@ const translations: TranslationDeepObject<typeof en> = {
         },
     },
     insightsPage: {
-        viewOnSpend: 'In Ausgaben anzeigen',
+        viewOnSpend: 'In Spend ansehen',
+        emptyState: {title: 'Nichts anzuzeigen', subtitle: 'Versuchen Sie, Ihre Kriterien oben anzupassen'},
+        noExpensesState: {title: 'Sehen Sie, wohin Ihr Geld fließt', subtitle: 'Sobald Sie Ausgaben haben, finden Sie Ausgabentrends, Top-Händler und mehr.'},
     },
     allSettingsScreen: {
         subscription: 'Abonnement',
diff --git a/src/languages/el.ts b/src/languages/el.ts
index a4b8cc02..9687b2f7 100644
--- a/src/languages/el.ts
+++ b/src/languages/el.ts
@@ -1217,6 +1217,8 @@ const translations: TranslationDeepObject<typeof en> = {
     },
     insightsPage: {
         viewOnSpend: 'Προβολή στο Spend',
+        emptyState: {title: 'Τίποτα προς εμφάνιση', subtitle: 'Δοκιμάστε να προσαρμόσετε τα κριτήριά σας παραπάνω'},
+        noExpensesState: {title: 'Δείτε πού πηγαίνουν τα χρήματά σας', subtitle: 'Μόλις έχετε δαπάνες, θα βλέπετε τάσεις δαπανών, κορυφαίους εμπόρους και άλλα.'},
     },
     allSettingsScreen: {
         subscription: 'Συνδρομή',
diff --git a/src/languages/es.ts b/src/languages/es.ts
index 69f656ee..c37b0278 100644
--- a/src/languages/es.ts
+++ b/src/languages/es.ts
@@ -1166,7 +1166,9 @@ const translations: TranslationDeepObject<typeof en> = {
         },
     },
     insightsPage: {
-        viewOnSpend: 'Ver en Gastos',
+        viewOnSpend: 'Ver en Spend',
+        emptyState: {title: 'Nada que mostrar', subtitle: 'Prueba a ajustar tus criterios de arriba'},
+        noExpensesState: {title: 'Ve adónde va tu dinero', subtitle: 'Una vez que tengas gastos, encontrarás tendencias de gasto, principales comercios y mucho más.'},
     },
     allSettingsScreen: {
         subscription: 'Suscripcion',
diff --git a/src/languages/fr.ts b/src/languages/fr.ts
index 3f4fd128..99de7c4c 100644
--- a/src/languages/fr.ts
+++ b/src/languages/fr.ts
@@ -1170,7 +1170,12 @@ const translations: TranslationDeepObject<typeof en> = {
         },
     },
     insightsPage: {
-        viewOnSpend: 'Voir dans Dépenses',
+        viewOnSpend: 'Voir dans Spend',
+        emptyState: {title: 'Rien à afficher', subtitle: 'Essayez de modifier vos critères ci-dessus'},
+        noExpensesState: {
+            title: 'Voyez où va votre argent',
+            subtitle: 'Une fois que vous aurez des dépenses, vous verrez des tendances de dépenses, les principaux marchands et plus encore.',
+        },
     },
     allSettingsScreen: {
         subscription: 'Abonnement',
diff --git a/src/languages/it.ts b/src/languages/it.ts
index e0695363..2ff40109 100644
--- a/src/languages/it.ts
+++ b/src/languages/it.ts
@@ -1167,7 +1167,9 @@ const translations: TranslationDeepObject<typeof en> = {
         },
     },
     insightsPage: {
-        viewOnSpend: 'Visualizza in Spese',
+        viewOnSpend: 'Vedi in Spend',
+        emptyState: {title: 'Niente da mostrare', subtitle: 'Prova a modificare i criteri qui sopra'},
+        noExpensesState: {title: 'Scopri dove va il tuo denaro', subtitle: 'Una volta che avrai delle spese, troverai tendenze di spesa, principali esercenti e altro ancora.'},
     },
     allSettingsScreen: {
         subscription: 'Abbonamento',
diff --git a/src/languages/ja.ts b/src/languages/ja.ts
index d4262861..f03b7a9a 100644
--- a/src/languages/ja.ts
+++ b/src/languages/ja.ts
@@ -1154,7 +1154,9 @@ const translations: TranslationDeepObject<typeof en> = {
         },
     },
     insightsPage: {
-        viewOnSpend: '支出で表示',
+        viewOnSpend: 'Spend で表示',
+        emptyState: {title: '表示するものはありません', subtitle: '上の条件を調整してみてください'},
+        noExpensesState: {title: 'お金の使い道を確認する', subtitle: '経費が登録されると、支出の傾向や上位の加盟店など、さまざまな情報を確認できるようになります。'},
     },
     allSettingsScreen: {
         subscription: 'サブスクリプション',
diff --git a/src/languages/nl.ts b/src/languages/nl.ts
index 3d9157d2..3231c487 100644
--- a/src/languages/nl.ts
+++ b/src/languages/nl.ts
@@ -1166,7 +1166,9 @@ const translations: TranslationDeepObject<typeof en> = {
         },
     },
     insightsPage: {
-        viewOnSpend: 'Bekijken in Uitgaven',
+        viewOnSpend: 'Bekijken in Spend',
+        emptyState: {title: 'Niets om weer te geven', subtitle: 'Probeer je criteria hierboven aan te passen'},
+        noExpensesState: {title: 'Zie waar je geld naartoe gaat', subtitle: 'Zodra je uitgaven hebt, zie je bestedingspatronen, topverkopers en meer.'},
     },
     allSettingsScreen: {
         subscription: 'Abonnement',
diff --git a/src/languages/pl.ts b/src/languages/pl.ts
index 93e61613..a0313454 100644
--- a/src/languages/pl.ts
+++ b/src/languages/pl.ts
@@ -1185,7 +1185,9 @@ const translations: TranslationDeepObject<typeof en> = {
         },
     },
     insightsPage: {
-        viewOnSpend: 'Zobacz w Wydatkach',
+        viewOnSpend: 'Zobacz w Spend',
+        emptyState: {title: 'Nic do wyświetlenia', subtitle: 'Spróbuj zmienić kryteria powyżej'},
+        noExpensesState: {title: 'Zobacz, na co idą twoje pieniądze', subtitle: 'Gdy będziesz mieć wydatki, zobaczysz trendy w wydawaniu, najważniejszych sprzedawców i więcej.'},
     },
     allSettingsScreen: {
         subscription: 'Subskrypcja',
diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts
index 50437502..1877a72c 100644
--- a/src/languages/pt-BR.ts
+++ b/src/languages/pt-BR.ts
@@ -1166,7 +1166,9 @@ const translations: TranslationDeepObject<typeof en> = {
         },
     },
     insightsPage: {
-        viewOnSpend: 'Ver em Gastos',
+        viewOnSpend: 'Ver no Spend',
+        emptyState: {title: 'Nada para mostrar', subtitle: 'Tente ajustar seus critérios acima'},
+        noExpensesState: {title: 'Veja para onde vai o seu dinheiro', subtitle: 'Quando você tiver despesas, vai encontrar tendências de gastos, principais estabelecimentos e muito mais.'},
     },
     allSettingsScreen: {
         subscription: 'Assinatura',
diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts
index 60f5c157..4fc21d75 100644
--- a/src/languages/zh-hans.ts
+++ b/src/languages/zh-hans.ts
@@ -1120,7 +1120,9 @@ const translations: TranslationDeepObject<typeof en> = {
         },
     },
     insightsPage: {
-        viewOnSpend: '在支出中查看',
+        viewOnSpend: '在 Spend 中查看',
+        emptyState: {title: '没有可显示的内容', subtitle: '请尝试调整上面的条件'},
+        noExpensesState: {title: '查看你的资金流向', subtitle: '添加报销后,您就能查看消费趋势、主要商家等更多信息。'},
     },
     allSettingsScreen: {
         subscription: '订阅',

Note

You can apply these changes to your branch by copying the patch to your clipboard, then running pbpaste | git apply 😉

View workflow run

@mhawryluk
mhawryluk marked this pull request as ready for review September 21, 2026 10:58
@mhawryluk
mhawryluk requested review from a team as code owners September 21, 2026 10:58
@melvin-bot
melvin-bot Bot requested a review from truph01 September 21, 2026 10:58
@melvin-bot

melvin-bot Bot commented Sep 21, 2026

Copy link
Copy Markdown

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

@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and removed request for a team September 21, 2026 10:58
@github-actions

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

This PR looks solid overall! I'm assuming that we'll add the tables in the follow-up PR, right?

@mhawryluk

Copy link
Copy Markdown
Member Author

@mhawryluk On mobile web, I’m unable to scroll the "Insights" page when swiping over a chart. I can only scroll when swiping over the empty space between charts:

good catch, it's also been the case in Home, but here is much more noticeable. I set the web-only touchAction prop on GestureDetector in charts, so that the browser keeps handling the vertical scroll. should work now:

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-09-22.at.14.19.36.mov

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Who else needs to approve so we can get this merged?

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

LGTM

@luacmartins
luacmartins merged commit fcacbdf into Expensify:main Sep 22, 2026
39 of 41 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

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

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

@jponikarchuk

Copy link
Copy Markdown

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

@jponikarchuk

Copy link
Copy Markdown

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.92-8 🚀

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.