Skip to content

Create SpendOverTime widget for the Home page#85417

Merged
puneetlath merged 32 commits intoExpensify:mainfrom
software-mansion-labs:feat/spend-over-time-widget
Mar 24, 2026
Merged

Create SpendOverTime widget for the Home page#85417
puneetlath merged 32 commits intoExpensify:mainfrom
software-mansion-labs:feat/spend-over-time-widget

Conversation

@mhawryluk
Copy link
Copy Markdown
Contributor

@mhawryluk mhawryluk commented Mar 16, 2026

Explanation of Change

Adds a new SpendOverTime widget to the Home page that displays a line chart for eligible users, with a "View" button that navigates to the full Search chart view. Refactors chart components to be composable by extracting the ChartHeader, container styling, and scroll handling out of the chart content components, making them reusable in both the Search page and the new Home page widget.

The insight still uses the "Year to date" date preset. It will be updated to "Last 12 months" in a separate PR.

Fixed Issues

$ #85349
PROPOSAL: N/A

Tests

  1. Verify the "Spend over time" widget appears on the Home page for users who are admin/auditor/approver on a paid policy.
  2. Verify the widget does not appear for users without eligible policies
  3. Verify the chart widget shows the same “Spend over time” line chart as in the Reports tab.
  4. Click on the “View” button. It should navigate to the Reports tab, showing the “Spend over time” suggested search.
  5. Verify the existing Search page chart views still work correctly (line, bar, pie) and that hovering over clickable elements on the charts shows a pointer cursor on desktop web.
  6. Go back to Home page.
  7. Simulate failing network. Verify the widget shows an "Oops... something went wrong" message.
  8. On web: go to Reports, open a search different than "Spend over time", go to Home, refresh page, go to Reports tab again, verify there is that different search shown, not "Spend over time".

Offline tests

  1. Verify the widget shows a "You are offline" message when the user is offline and there is no fetched data. (Go to Account > Troubleshooting > Clear cache and restart > Force offline > Go to home page).
  2. Verify the data is fetched and displayed after going back online.
  3. If there is some stale data already fetched, a chart should be shown instead of the offline indicator.

QA Steps

Same as 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 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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 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 a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
Nagranie.z.ekranu.2026-03-17.o.11.50.01.mov
Android: mWeb Chrome
Nagranie.z.ekranu.2026-03-17.o.11.48.39.mov
iOS: Native
Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2026-03-24.at.11.34.24.mp4
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2026-03-17.at.11.47.01.mp4
MacOS: Chrome / Safari
Nagranie.z.ekranu.2026-03-17.o.11.24.21.mov
Nagranie.z.ekranu.2026-03-17.o.11.26.41.mov

Copy link
Copy Markdown
Contributor

@mateuuszzzzz mateuuszzzzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I only left a couple of NABs

Copy link
Copy Markdown
Contributor

@borys3kk borys3kk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall changes looks great! 🚀

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

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 Δ
src/components/Button/index.tsx 92.02% <100.00%> (ø)
...mponents/Search/FilterDropdowns/DropdownButton.tsx 93.10% <100.00%> (+0.51%) ⬆️
src/components/Search/SearchBarChart.tsx 12.50% <ø> (ø)
src/components/Search/SearchLineChart.tsx 0.00% <ø> (-12.50%) ⬇️
src/components/Search/SearchPieChart.tsx 12.50% <ø> (ø)
src/components/WidgetContainer.tsx 100.00% <ø> (ø)
src/libs/PolicyUtils.ts 61.47% <100.00%> (+0.22%) ⬆️
src/libs/ReportPrimaryActionUtils.ts 91.78% <100.00%> (ø)
src/libs/ReportSecondaryActionUtils.ts 92.91% <100.00%> (ø)
src/libs/SearchUIUtils.ts 71.31% <100.00%> (-0.03%) ⬇️
... and 22 more
... and 15 files with indirect coverage changes

@mhawryluk
Copy link
Copy Markdown
Contributor Author

mhawryluk commented Mar 17, 2026

cc: @shawnborton

  1. I updated the size of the icon in small dropdown buttons as requested:

before:
Zrzut ekranu 2026-03-17 o 11 32 27

after:
Zrzut ekranu 2026-03-17 o 11 31 59

  1. without a "no data" empty state (so instead not showing the widget at all when there is no data to show), we could run into a situation in which we show the widget with a loading spinner, then when we get the data and it turns out empty and so the widget disappears. is that okay?
Nagranie.z.ekranu.2026-03-17.o.11.35.04.mov
  1. I made the widget always have a constant height, so that there is no layout shift between spinner <-> data loaded. so instead of the chart view expanding its height to fit the labels, instead it shrinks the plot area to make room for the labels. I think in this case it won't lead to problems with the plot area being tiny if the labels are long, cause it's just month names and years (charts in Reports tab still work the same). but if we're okay with the dynamic height for the widget on the home page, then I could simplify the logic (I think other widgets, like "For you" don't have a constant height either).
Zrzut ekranu 2026-03-17 o 12 16 52 Zrzut ekranu 2026-03-17 o 12 17 11

@mhawryluk mhawryluk marked this pull request as ready for review March 17, 2026 11:34
@mhawryluk mhawryluk requested review from a team as code owners March 17, 2026 11:34
@melvin-bot melvin-bot bot requested review from JmillsExpensify and truph01 and removed request for a team March 17, 2026 11:34
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Mar 17, 2026

@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 removed the request for review from a team March 17, 2026 11:34
@melvin-bot melvin-bot bot requested a review from puneetlath March 24, 2026 17:27
@puneetlath
Copy link
Copy Markdown
Contributor

Great PR. Let's see how it goes!!

@puneetlath puneetlath merged commit 33c1479 into Expensify:main Mar 24, 2026
32 of 33 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

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

@trjExpensify
Copy link
Copy Markdown
Contributor

@mhawryluk @truph01 why is the label vertical when there's clearly space for it to be horizontal?

image
  1. Sign up for a new account
  2. Create an expense
  3. Go to Home

I was checking out: https://85417.pr-testing.expensify.com/

Copy link
Copy Markdown
Contributor

Also, not sure if this is confined to this PR, but OpenApp took a super long time. I was waiting minimally 45 secs to a minute.

Copy link
Copy Markdown
Contributor

The graph looked fine for me though.

CleanShot_2026-03-24_at_22.58.15_2x-2026-03-24 22_01_49.729.png

@trjExpensify
Copy link
Copy Markdown
Contributor

What about for a n00b account?

@borys3kk
Copy link
Copy Markdown
Contributor

@mhawryluk @truph01 why is the label vertical when there's clearly space for it to be horizontal?

image 1. Sign up for a new account 2. Create an expense 3. Go to Home

I was checking out: https://85417.pr-testing.expensify.com/

I've also found this bug while testing paragraphAPI, I will fix it in my pr

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/puneetlath in version: 9.3.44-0 🚀

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

Bundle Size Analysis (Sentry):

@lanitochka17
Copy link
Copy Markdown

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

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/puneetlath in version: 9.3.47-0 🚀

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

Bundle Size Analysis (Sentry):

@jponikarchuk
Copy link
Copy Markdown

This PR failing because of the issue #86392 in offline mode
This issue is reproducible in: Web, Android

@jponikarchuk
Copy link
Copy Markdown

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

@adamgrzybowski
Copy link
Copy Markdown
Contributor

@trjExpensify FYI, @mhawryluk is on a business trip currently. He will be able to look into the blocker on Monday

@trjExpensify
Copy link
Copy Markdown
Contributor

Thanks for the heads up! @mateuuszzzzz @puneetlath is this just another flavour of #86336 which we decided to handle as a follow-up?

@borys3kk borys3kk mentioned this pull request Mar 26, 2026
52 tasks
@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.3.48-2 🚀

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

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.