[Home Page] Fix: Your spend section does not update after updating expense offline#93081
Conversation
Patch awaiting-approval and repaid snapshot search.total aggregates optimistically when money request amounts change, since Home cannot refetch those totals while offline.
Import Your spend query builders directly from @libs/YourSpendQueryUtils instead of a page-local re-export barrel, giving a single source of truth.
|
@ZhenjaHorbach 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] |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@adamgrzybowski lint |
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Good for product
Replace unsafe type assertions with a typed createRandomPolicy factory and typed getSnapshotKey/buildSnapshotSearchResults helpers.
|
@grgia fixed |
|
Looks like changes don't work if we reject submitted expenses 2026-06-11.14.48.04.mov |
|
@ZhenjaHorbach Yeah, the question is how big the scope should be for this PR and which actions should be supported. This issue is also mentioned here #93081 (comment) |
I believe all actions should be supported, and the amount should be the same as after the response from BE |
|
@ZhenjaHorbach do you know exactly which actions?
Something else? |
I suppose in the context of this flow, at least retract, unapprove, reject |
|
Actively working on this one |
Scope the useOnyx selector to only the id, type, and outputCurrency fields the snapshot builders read, so subscribers re-render only on relevant paid-policy changes.
|
@grgia ready for next steps |
# Conflicts: # src/components/MoneyReportHeaderPrimaryAction/SubmitPrimaryAction.tsx # src/hooks/useHoldMenuSubmit.ts # src/libs/actions/IOU/ReportWorkflow.ts
4254814 to
5b266b1
Compare
|
🚧 grgia has triggered a test Expensify/App build. You can view the workflow run here. |
grgia
left a comment
There was a problem hiding this comment.
Confirming where we landed on this
Submitting, approving, or paying a report from the Reports page while offline can leave the Home totals stale when that report's expenses were never loaded outside search.
@adamgrzybowski do we handle search entry points? It's an edge case so NAB
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
| // to draft) so they can resubmit — matching the pre-submit-via-PDF behavior. | ||
| openPDFDownload({ | ||
| onCancel: () => | ||
| retractReport( |
There was a problem hiding this comment.
should we pass getYourSpendPatchData() in retractReport here too?
There was a problem hiding this comment.
The current solution feels a bit odd to me. It seems like we have all the data locally, can we just derive these values directly from the data instead of using and patching the snapshot?
An alternate solution would be to just grey out these values if any offline action is taken, but I'd confirm that approach with product first cc @trjExpensify
|
Yeah, the alt of applying the "pending update" offline treatment seems fine for this case. It signals enough that "these totals are no longer accurate in the current state" until coming back online. |
Yes |
|
Can't derive locally. The totals come from server search snapshots that may include reports not in Onyx, so recomputing would undercount. That's why I patch the snapshot. But yeah, we can just grey out the value instead of all this computation. Up to you |
|
I don't feel strongly, so defer to @luacmartins and @trjExpensify |
|
I'd prefer to just grey it out and not run a bunch of complex logic that may also be incorrect given that we don't have all the data locally. I'll defer to @trjExpensify since this is mostly a product decision. |
|
Cool, sounds like we're aligned that applying "pending update" to grey out the value until coming back online will suffice. 👍 |
|
Agree with simplicity and ui feedback here |
|
Okay. In that case, I guess I should close this PR and create a new one with greyed out value. Can you confirm? |
|
@grgia You fine with that as well? |
Either that or update this PR to handle that behavior |
|
Yes we can move forward with #93081 (comment) @adamgrzybowski |
|
Feel free to open a new pr or update this one |
Explanation of Change
Fixed Issues
$ #91370
PROPOSAL:
Tests
Offline tests
QA Steps
Prerequisites: a paid group workspace (Team/Corporate) where you are a member, and a few of your own reimbursable expenses. Each suite is run while offline (disable your network connection), starting from Home where you note the current "Your spend" totals.
Suite 1 - Awaiting approval increases
Suite 2 - Awaiting approval decreases
Suite 3 - Repaid (last 30 days)
Suite 4 - Rollback and reconciliation
Suite 5 - Negative checks (totals must not change)
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
Screen.Recording.2026-06-09.at.16.05.31.mov