Repository navigation
[NoQA] [Insights] Show already-loaded charts on Insights and Home/Spend when fetched by different actions - #102311
Conversation
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.
|
…ts snapshots, until backend fixes the response
|
@MelvinBot review |
ReviewI found one blocking issue. The rest of the change looks sound. 🔴 A failed
What the user sees with a fresh cache (your test step 7):
Suggested fix: Move the stamp from Other things I checked
|
OlGierd03
left a comment
There was a problem hiding this comment.
Looks great overall! 🚀
|
@truph01 I've addressed the comments |
| return INSIGHTS_DASHBOARD_STATE.NO_EXPENSES; | ||
| } | ||
| if (headlineSnapshot?.data && !Object.keys(headlineSnapshot.data).some(isGroupEntry)) { | ||
| if (chartStates.every(({isLoaded}) => isLoaded)) { |
There was a problem hiding this comment.
Could we exclude snapshots with errors here, so a failed Home Search doesn’t count as an empty result when opening Insights offline?
There was a problem hiding this comment.
good call. I changed isLoaded to isSearchDataLoaded(snapshot, queryJSON) && isEmptyObject(snapshot?.errors)
luacmartins
left a comment
There was a problem hiding this comment.
LGTM. @cristipaval @aldo-expensify all yours
|
@mhawryluk conflicts |
fa00934
|
@mhawryluk We have conflicts again |
8976c7e
|
🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.5.0-0 🚀
|
|
No help site update needed. This PR changes how Insights charts load and show offline or empty states, and the Insights page and Home insights widget are still gated behind the |
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.5.0-5 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
The Insights page and the Home insights widget can load the same chart with different commands (
GetInsightsandSearch), and both write it to the same snapshot key. Each could only partly use what the other loaded: Insights only once its own GetInsights response had named the snapshot, and Home not at all, since GetInsights snapshots had no state stamp and reported the wrong search metadata.getInsightsnow stamps each graph's snapshot withstate: loadedinsuccessData, the same waysearchdoes infinallyData. This lets Search readers like the Home widget treat those snapshots as loaded. Insights charts read their snapshot under their own query's hash instead of going through the dashboard record. A chart counts as loaded once the snapshot is loaded, not matter what command sent it.The page now decides its state from every visible chart instead of only the headline. It shows the full-page offline state only when no chart has anything to show, and otherwise renders the charts, each with its own offline, loading or empty state. It shows the full-page empty state only when every chart is loaded without rows. Nothing is requested or read until the saved filters resolve, and each chart shows its loading state until then.
Fixed Issues
$ #102515
PROPOSAL: N/A
Tests
Precondition: the
insightsPagebeta is enabled and the account is an admin of a workspace with expenses this year.Offline tests
QA Steps
No tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Nagranie.z.ekranu.2026-09-29.o.11.11.33.mov