Skip to content

[NoQA] [Insights] Draw Previous period for Spend over time - #103786

Merged
luacmartins merged 24 commits into
Expensify:mainfrom
software-mansion-labs:insights/previous-period-line
Oct 20, 2026
Merged

luacmartins merged 24 commits into
Expensify:mainfrom
software-mansion-labs:insights/previous-period-line

Conversation

@mhawryluk

@mhawryluk mhawryluk commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Explanation of Change

Spend over time now draws the previous period as a second line when Compare is set to Previous period.

  • In presets, a day is paired with the same date in the previous period, so a day the previous period doesn't have, like October 31 against September, gets no compared value and the line breaks there instead of dropping to $0. Other buckets, and every bucket in a custom range, are paired by position, like the second week with the second week.
  • Buckets that share a calendar name are labeled by it, like "April". Others are labeled by position, like "Week 2", or just "Week" when the period has only one.
  • The previous period comes from the Date filter: This month, Last month and Last 12 months compare against the same span of months before, Year to date compares against the same days of last year, and custom ranges compare against the same number of days just before.
  • The current period's line and dot are drawn on top, and only its last segment is dashed while the period is still in progress.
  • Hovering shows a dot on each line and a tooltip with a row per period (its amount and share of that period's spend), plus how the current period changed against the previous one. A previous period of $0 shows the change percentage as a dash.
  • Clicking a point opens that current bucket's dates in Spend (on web).

Fixed Issues

$ #103768
PROPOSAL: N/A

Tests

  1. Enable the insightsPage and insightsCompare betas. Go to Insights and set Date to Year to date, Group by to Month and Compare to Previous period. Verify that Spend over time shows two lines: the current year, and last year in a lighter shade of the same color, with the current line drawn on top.
  2. Hover over a point on desktop web, or tap it on other platforms. Verify that the tooltip is titled with the month, like "April", and has one row per period, like "2026: [amount] ([share]%)" and "2025: [amount] ([share]%)", followed by the change with an arrow and percentage.
  3. Verify that only the current line's last segment is dashed while the current month is still in progress, and that the previous year's line is solid all the way.
  4. Set Group by to Week. Verify that the tooltip titles the points by position, like "Week 2", since the weeks of the two years share no calendar name.
  5. Set Date to This month and Group by to Day. Verify that the line for the previous month stops where that month has no matching day, like October 31 against September, instead of dropping to $0.
  6. Set Date to Last month and Group by to Day. Add an expense dated August 31st. Verify that the previous period's line ends with a point for the 31st after September 30, where the current line has no point. Hover or tap it (on mobile) and verify that the tooltip is titled "31st" and shows only "August 2026: [amount]", with no change line.
  7. Find a point where the previous period had no expenses. Verify that the tooltip shows the change percentage as —.
  8. On desktop web, click a point. Verify that Spend opens filtered to that point's dates in the current period.
  9. Set a custom Date range of October 1 to October 31, 2026 and Group by to Day. Hover or tap the first point. Verify that the tooltip rows are named "Oct 1, 2026" and "Aug 31, 2026", since a custom range compares against the same number of days just before it.
  10. Set Date to This month and add an expense dated the last day of the month before last. Verify that it isn't counted in the previous period.
  11. Set Compare to Average. Verify that Spend over time shows the Average line, as before this change.
  12. Switch to dark mode and verify that the previous period's line and tooltip dot use the darker shade.
  13. Set Compare to None and verify that all charts look as they did before this change.

Offline tests

  1. Load Insights with Compare set to Previous period, then go offline. Verify that Spend over time keeps showing both lines.
  2. While offline, change the Date filter. Verify that charts without loaded data show the offline state, not one line that turns into two later.
  3. Go back online. Verify that the charts load and show both lines.
  4. Go online. Clear cache and restart. Load a chart on Home. Go offline. Go to Insights. Set Compare to Previous period. Verify that Spend over time shows an offline state.

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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Nagranie.z.ekranu.2026-10-16.o.13.11.35.mov

@melvin-bot

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

@mhawryluk
mhawryluk force-pushed the insights/previous-period-line branch from b744ce3 to 81e9900 Compare October 14, 2026 15:27
@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 0cea6445..140d40ee 100644
--- a/src/languages/de.ts
+++ b/src/languages/de.ts
@@ -1176,7 +1176,16 @@ const translations: TranslationDeepObject<typeof en> = {
         viewOnSpend: 'In Ausgaben anzeigen',
         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.'},
-        compare: {label: 'Vergleichen', previousPeriod: 'Vorheriger Zeitraum', average: 'Durchschnitt'},
+        compare: {
+            label: 'Vergleichen',
+            previousPeriod: 'Vorheriger Zeitraum',
+            average: 'Durchschnitt',
+            dayLabel: (day?: number) => (day === undefined ? 'Tag' : `Tag ${day}`),
+            weekLabel: (week?: number) => (week === undefined ? 'Woche' : `Woche ${week}`),
+            monthLabel: (month?: number) => (month === undefined ? 'Monat' : `Monat ${month}`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? 'Quartal' : `Quartal ${quarter}`),
+            yearLabel: (year?: number) => (year === undefined ? 'Jahr' : `Jahr ${year}`),
+        },
     },
     allSettingsScreen: {
         subscription: 'Abonnement',
diff --git a/src/languages/el.ts b/src/languages/el.ts
index 8ae8d6e7..dfc6d0af 100644
--- a/src/languages/el.ts
+++ b/src/languages/el.ts
@@ -1221,7 +1221,16 @@ const translations: TranslationDeepObject<typeof en> = {
         viewOnSpend: 'Προβολή στο Spend',
         emptyState: {title: 'Τίποτα προς εμφάνιση', subtitle: 'Δοκιμάστε να προσαρμόσετε τα κριτήριά σας παραπάνω'},
         noExpensesState: {title: 'Δείτε πού πηγαίνουν τα χρήματά σας', subtitle: 'Μόλις έχετε δαπάνες, θα βλέπετε τάσεις δαπανών, κορυφαίους εμπόρους και άλλα.'},
-        compare: {label: 'Σύγκριση', previousPeriod: 'Προηγούμενη περίοδος', average: 'Μέσος όρος'},
+        compare: {
+            label: 'Σύγκριση',
+            previousPeriod: 'Προηγούμενη περίοδος',
+            average: 'Μέσος όρος',
+            dayLabel: (day?: number) => (day === undefined ? 'Ημέρα' : `Ημέρα ${day}`),
+            weekLabel: (week?: number) => (week === undefined ? 'Εβδομάδα' : `Εβδομάδα ${week}`),
+            monthLabel: (month?: number) => (month === undefined ? 'Μήνας' : `Μήνας ${month}`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? 'Τρίμηνο' : `Τρίμηνο ${quarter}`),
+            yearLabel: (year?: number) => (year === undefined ? 'Έτος' : `Έτος ${year}`),
+        },
     },
     allSettingsScreen: {
         subscription: 'Συνδρομή',
diff --git a/src/languages/es.ts b/src/languages/es.ts
index 23fc4be3..ed34a7ce 100644
--- a/src/languages/es.ts
+++ b/src/languages/es.ts
@@ -1171,7 +1171,16 @@ const translations: TranslationDeepObject<typeof en> = {
         viewOnSpend: 'Ver en Gastos',
         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.'},
-        compare: {label: 'Comparar', previousPeriod: 'Periodo anterior', average: 'Promedio'},
+        compare: {
+            label: 'Comparar',
+            previousPeriod: 'Periodo anterior',
+            average: 'Promedio',
+            dayLabel: (day?: number) => (day === undefined ? 'Día' : `Día ${day}`),
+            weekLabel: (week?: number) => (week === undefined ? 'Semana' : `Semana ${week}`),
+            monthLabel: (month?: number) => (month === undefined ? 'Mes' : `Mes ${month}`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? 'Trimestre' : `Trimestre ${quarter}`),
+            yearLabel: (year?: number) => (year === undefined ? 'Año' : `Año ${year}`),
+        },
     },
     allSettingsScreen: {
         subscription: 'Suscripcion',
diff --git a/src/languages/fr.ts b/src/languages/fr.ts
index 7f37b163..185b9cac 100644
--- a/src/languages/fr.ts
+++ b/src/languages/fr.ts
@@ -1180,7 +1180,16 @@ const translations: TranslationDeepObject<typeof en> = {
             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.',
         },
-        compare: {label: 'Comparer', previousPeriod: 'Période précédente', average: 'Moyenne'},
+        compare: {
+            label: 'Comparer',
+            previousPeriod: 'Période précédente',
+            average: 'Moyenne',
+            dayLabel: (day?: number) => (day === undefined ? 'Jour' : `Jour ${day}`),
+            weekLabel: (week?: number) => (week === undefined ? 'Semaine' : `Semaine ${week}`),
+            monthLabel: (month?: number) => (month === undefined ? 'Mois' : `Mois ${month}`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? 'Trimestre' : `Trimestre ${quarter}`),
+            yearLabel: (year?: number) => (year === undefined ? 'Année' : `Année ${year}`),
+        },
     },
     allSettingsScreen: {
         subscription: 'Abonnement',
diff --git a/src/languages/it.ts b/src/languages/it.ts
index bd8eb402..c587e28d 100644
--- a/src/languages/it.ts
+++ b/src/languages/it.ts
@@ -1176,7 +1176,16 @@ const translations: TranslationDeepObject<typeof en> = {
         viewOnSpend: 'Visualizza in Spese',
         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.'},
-        compare: {label: 'Confronta', previousPeriod: 'Periodo precedente', average: 'Media'},
+        compare: {
+            label: 'Confronta',
+            previousPeriod: 'Periodo precedente',
+            average: 'Media',
+            dayLabel: (day?: number) => (day === undefined ? 'Giorno' : `Giorno ${day}`),
+            weekLabel: (week?: number) => (week === undefined ? 'Settimana' : `Settimana ${week}`),
+            monthLabel: (month?: number) => (month === undefined ? 'Mese' : `Mese ${month}`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? 'Trimestre' : `Trimestre ${quarter}`),
+            yearLabel: (year?: number) => (year === undefined ? 'Anno' : `Anno ${year}`),
+        },
     },
     allSettingsScreen: {
         subscription: 'Abbonamento',
diff --git a/src/languages/ja.ts b/src/languages/ja.ts
index 7da59e4d..d6884724 100644
--- a/src/languages/ja.ts
+++ b/src/languages/ja.ts
@@ -1164,7 +1164,16 @@ const translations: TranslationDeepObject<typeof en> = {
         viewOnSpend: '支出で表示',
         emptyState: {title: '表示するものはありません', subtitle: '上の条件を調整してみてください'},
         noExpensesState: {title: 'お金の使い道を確認する', subtitle: '経費が登録されると、支出の傾向や上位の加盟店など、さまざまな情報を確認できるようになります。'},
-        compare: {label: '比較', previousPeriod: '前の期間', average: '平均'},
+        compare: {
+            label: '比較',
+            previousPeriod: '前の期間',
+            average: '平均',
+            dayLabel: (day?: number) => (day === undefined ? '日' : `${day} 日目`),
+            weekLabel: (week?: number) => (week === undefined ? '週' : `${week}週目`),
+            monthLabel: (month?: number) => (month === undefined ? '月' : `月 ${month}`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? '四半期' : `四半期 ${quarter}`),
+            yearLabel: (year?: number) => (year === undefined ? '年' : `${year}年`),
+        },
     },
     allSettingsScreen: {
         subscription: 'サブスクリプション',
diff --git a/src/languages/nl.ts b/src/languages/nl.ts
index b96c6121..1409f824 100644
--- a/src/languages/nl.ts
+++ b/src/languages/nl.ts
@@ -1175,7 +1175,16 @@ const translations: TranslationDeepObject<typeof en> = {
         viewOnSpend: 'Bekijken in Uitgaven',
         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.'},
-        compare: {label: 'Vergelijken', previousPeriod: 'Vorige periode', average: 'Gemiddeld'},
+        compare: {
+            label: 'Vergelijken',
+            previousPeriod: 'Vorige periode',
+            average: 'Gemiddeld',
+            dayLabel: (day?: number) => (day === undefined ? 'Dag' : `Dag ${day}`),
+            weekLabel: (week?: number) => (week === undefined ? 'Week' : `Week ${week}`),
+            monthLabel: (month?: number) => (month === undefined ? 'Maand' : `Maand ${month}`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? 'Kwartaal' : `Kwartaal ${quarter}`),
+            yearLabel: (year?: number) => (year === undefined ? 'Jaar' : `Jaar ${year}`),
+        },
     },
     allSettingsScreen: {
         subscription: 'Abonnement',
diff --git a/src/languages/pl.ts b/src/languages/pl.ts
index 95e7b90a..1fb1cfe6 100644
--- a/src/languages/pl.ts
+++ b/src/languages/pl.ts
@@ -1197,7 +1197,16 @@ const translations: TranslationDeepObject<typeof en> = {
         viewOnSpend: 'Zobacz w Wydatkach',
         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.'},
-        compare: {label: 'Porównaj', previousPeriod: 'Poprzedni okres', average: 'Średnia'},
+        compare: {
+            label: 'Porównaj',
+            previousPeriod: 'Poprzedni okres',
+            average: 'Średnia',
+            dayLabel: (day?: number) => (day === undefined ? 'Dzień' : `Dzień ${day}`),
+            weekLabel: (week?: number) => (week === undefined ? 'Tydzień' : `Tydzień ${week}`),
+            monthLabel: (month?: number) => (month === undefined ? 'Miesiąc' : `Miesiąc ${month}`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? 'Kwartał' : `Kwartał ${quarter}`),
+            yearLabel: (year?: number) => (year === undefined ? 'Rok' : `Rok ${year}`),
+        },
     },
     allSettingsScreen: {
         subscription: 'Subskrypcja',
diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts
index 0a675362..513ae2b8 100644
--- a/src/languages/pt-BR.ts
+++ b/src/languages/pt-BR.ts
@@ -1175,7 +1175,16 @@ const translations: TranslationDeepObject<typeof en> = {
         viewOnSpend: 'Ver em Gastos',
         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.'},
-        compare: {label: 'Comparar', previousPeriod: 'Período anterior', average: 'Média'},
+        compare: {
+            label: 'Comparar',
+            previousPeriod: 'Período anterior',
+            average: 'Média',
+            dayLabel: (day?: number) => (day === undefined ? 'Dia' : `Dia ${day}`),
+            weekLabel: (week?: number) => (week === undefined ? 'Semana' : `Semana ${week}`),
+            monthLabel: (month?: number) => (month === undefined ? 'Mês' : `Mês ${month}`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? 'Trimestre' : `Trimestre ${quarter}`),
+            yearLabel: (year?: number) => (year === undefined ? 'Ano' : `Ano ${year}`),
+        },
     },
     allSettingsScreen: {
         subscription: 'Assinatura',
diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts
index 3b4ae9ff..ce04b889 100644
--- a/src/languages/zh-hans.ts
+++ b/src/languages/zh-hans.ts
@@ -1129,7 +1129,16 @@ const translations: TranslationDeepObject<typeof en> = {
         viewOnSpend: '在支出中查看',
         emptyState: {title: '没有可显示的内容', subtitle: '请尝试调整上面的条件'},
         noExpensesState: {title: '查看你的资金流向', subtitle: '添加报销后,您就能查看消费趋势、主要商家等更多信息。'},
-        compare: {label: '比较', previousPeriod: '上一期', average: '平均'},
+        compare: {
+            label: '比较',
+            previousPeriod: '上一期',
+            average: '平均',
+            dayLabel: (day?: number) => (day === undefined ? '天' : `第 ${day} 天`),
+            weekLabel: (week?: number) => (week === undefined ? '周' : `第 ${week} 周`),
+            monthLabel: (month?: number) => (month === undefined ? '月' : `第 ${month} 个月`),
+            quarterLabel: (quarter?: number) => (quarter === undefined ? '季度' : `第 ${quarter} 季度`),
+            yearLabel: (year?: number) => (year === undefined ? '年份' : `${year} 年`),
+        },
     },
     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

Copy link
Copy Markdown
Member Author

@MelvinBot review, but only the changes on top of this other PR's branch: #103989

@codecov

codecov Bot commented Oct 16, 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 Δ
...components/Charts/utils/formatTooltipComparison.ts 96.15% <100.00%> (+4.15%) ⬆️
src/components/Search/SearchChartView.tsx 82.92% <ø> (ø)
src/components/Search/buildChartSeries.ts 100.00% <100.00%> (+7.01%) ⬆️
src/components/Search/chartGroupByConfig.ts 34.78% <ø> (+13.04%) ⬆️
src/pages/Insights/insightsCompare.ts 94.44% <100.00%> (+0.69%) ⬆️
src/pages/Insights/useInsightsChartData.ts 59.25% <0.00%> (-1.46%) ⬇️
src/pages/Insights/charts/InsightsDataTable.tsx 30.55% <0.00%> (-1.80%) ⬇️
src/components/Search/comparisonBuckets.ts 94.73% <94.73%> (ø)
... and 68 files with indirect coverage changes

@MelvinBot

Copy link
Copy Markdown
Contributor

I reviewed only the 9 commits this PR adds on top of [NoQA] [Insights] Draw Average mode baseline on Spend over time (c187c5e → 2714320, 27 files). Bucket pairing, labels and period math look right overall. I found one real gap, one regression in Average mode, and two small issues.

1. Previous-period spend disappears in buckets where the current period has no expenses. buildChartSeries.ts:115 builds the x-axis only from the current search's rows. A search returns only buckets that hold expenses, so a previous bucket without a current partner is never drawn. Your own test shows this at buildChartSeriesTest.ts:418: Q2 2025 ($200) is dropped, and the previous line runs straight from Q1 to Q3. With Group by Day, a current month with no spend on the 5th hides last month's spend on the 5th. Consider building the full bucket sequence for the current period (up to today) when comparing, with 0 for empty current buckets.

2. Average mode lost the base PR's tooltip fallback. Changing the guard to !comparedSeries at formatTooltipComparison.ts:74 applies to Average too. A point with no average value now shows one unlabeled row with no expense count, which commit a20e5cd deliberately avoided. Average points never get seriesLabels, so that row has no name. Consider keeping the one-row tooltip only when the point has seriesLabels.

3. Custom ranges can be paired by calendar date instead of by position. getMonthShift also fires for a custom range whose start falls on the same day of the month as the previous start. Example: Jan 31 – Mar 2, 2026 compares against Dec 31 – Jan 30. The code at comparisonBuckets.ts:135 maps Mar 1 to Feb 1, which falls outside that range. So Mar 1–2 get no previous value, and Jan 29–30 are never shown. Using the month shift only for presets would fix this.

4. Translation nit. In ja.ts:1175 and zh-hans.ts:1140, ${year}年 reads as "2 years" or "year 2 AD". 第${year}年 (or ${year}年目 in ja) is clearer. The ja 月 ${month} at ja.ts:1173 would read better as ${month}か月目.

What I checked
  • resolveComparisonPeriods against getDateRangeForPreset: This month, Last month, Last 12 months and Year to date all produce the expected previous range.
  • The labels and pairing still rely on the backend computing the same previous period as resolveComparisonPeriods. If the two ever differ, points quietly show $0. Returning the compared range with the snapshot would remove that coupling.
  • CI checks pass, except the checklist and independent-approval checks. I traced the edge cases above by hand and didn't run them locally.

@mhawryluk

Copy link
Copy Markdown
Member Author

1. Previous-period spend disappears in buckets where the current period has no expenses.

the backend sends all buckets, even when they're empty. we're using the lack of a bucket to determine that it doesn't exist.

2. Average mode lost the base PR's tooltip fallback.

yeah, good catch, fixed

3. Custom ranges can be paired by calendar date instead of by position.

very very good point, fixed

4. Translation nit.

I'll have to trust Melvin on this one

@mhawryluk
mhawryluk marked this pull request as ready for review October 20, 2026 10:37
@JmillsExpensify

Copy link
Copy Markdown
Contributor

Also @dannymcclain added you for review. The adhoc links are above.

@dannymcclain

Copy link
Copy Markdown
Contributor

Looking good!

@truph01

truph01 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@mhawryluk Could you help confirm if it is the bug?

Setup: Need a workspace with expenses in both months:

  • Previous month: at least one expense dated after today’s day of the month. For example, if today is Oct 20, add one on Sep 25.
  • Current month: at least one expense dated today, so today’s day is the last bucket and is in progress.

Steps:

  1. Open Insights, then the Spend over time chart.
  2. Set the view to the line chart and Group by to Day.
  3. Set the Date filter to This month.
  4. Set Compare to Previous period.

Expected: The current-month line ends at today with a dashed last segment, since the period isn’t over.
Actual: The x-axis runs past today with points that only the previous period has (Sep 25 shows up as “25th”). The current line’s last segment is solid.

Screenshot 2026-10-20 at 22 12 31 Screenshot 2026-10-20 at 22 12 44

@mhawryluk

mhawryluk commented Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

@mhawryluk Could you help confirm if it is the bug?

Setup: Need a workspace with expenses in both months:

  • Previous month: at least one expense dated after today’s day of the month. For example, if today is Oct 20, add one on Sep 25.
  • Current month: at least one expense dated today, so today’s day is the last bucket and is in progress.

Steps:

  1. Open Insights, then the Spend over time chart.
  2. Set the view to the line chart and Group by to Day.
  3. Set the Date filter to This month.
  4. Set Compare to Previous period.

Expected: The current-month line ends at today with a dashed last segment, since the period isn’t over. Actual: The x-axis runs past today with points that only the previous period has (Sep 25 shows up as “25th”). The current line’s last segment is solid.

Screenshot 2026-10-20 at 22 12 31 Screenshot 2026-10-20 at 22 12 44

This month covers Oct 1-31 and the backend now sends every day, with $0 for the days after today, so the axis runs to the 31st. this happens even with Compare set to None, it's not related to the previous period. and I think it's expected

the last segment is solid because the line chart only dashes when the last point is in progress, and today isn't the last day of the month. but this PR: #104075 changes which line segments are dashed, it makes all current and future buckets dashed, so it will cover this scenario

@mhawryluk

mhawryluk commented Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

This month covers Oct 1-31 and the backend now sends every day, with $0 for the days after today, so the axis runs to the 31st. this happens even with Compare set to None, it's not related to the previous period. and I think it's expected

oh, I guess it's not expected, coming from this comment: #104272 (comment)
so we should filter out the future date buckets when they don't have expenses? @JmillsExpensify
(I can include this in this PR, though it's not really related)

@truph01

truph01 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

but this PR: #104075 changes which line segments are dashed, it makes all current and future buckets dashed, so it will cover this scenario

@mhawryluk I think if that PR already covers this scenario, we can leave it to handle the fix and avoid adding the same fix to our current PR since as you said, it doesn't cause by our PR

Comment thread src/components/Search/buildChartSeries.ts

Copy link
Copy Markdown
Contributor

Agree with that approach.

@truph01

truph01 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

but this PR: #104075 changes which line segments are dashed, it makes all current and future buckets dashed, so it will cover this scenario

@mhawryluk I think if that PR already covers this scenario, we can leave it to handle the fix and avoid adding the same fix to our current PR since as you said, it doesn't cause by our PR

Here is the behavior in PR #104075, it looks good:

Screenshot 2026-10-20 at 22 56 49

@mhawryluk

Copy link
Copy Markdown
Member Author

yeah, it looks good to me too. but it only changes where the line is dashed, we still plot empty buckets of the future, so if we wanted to change that we would need to filter them out. but I think we should do it in a follow-up, if we do decide we want to only show future buckets if they have expenses cc: @JmillsExpensify

@luacmartins

Copy link
Copy Markdown
Contributor

That chart with the future buckets looks good to me. cc @JmillsExpensify in case you feel differently

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Looks good to me too.

@truph01

truph01 commented Oct 20, 2026

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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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-10-21.at.00.32.40.mov
Android: mWeb Chrome
Screen.Recording.2026-10-21.at.00.33.58.mov
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-10-21.at.00.30.02.mov

@melvin-bot
melvin-bot Bot requested a review from cristipaval October 20, 2026 17:34
@luacmartins
luacmartins merged commit 527675f into Expensify:main Oct 20, 2026
38 of 47 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.5.15-1 🚀

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.5.15-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