Use freshly computed report totals from backend instead of potentially stale stored total#89047
Conversation
…optimistic updates
|
@mananjadhav 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] |
|
@mananjadhav please hold on the C+ review, @mountiny do we need a C+ to test this one ? |
|
🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
mananjadhav
left a comment
There was a problem hiding this comment.
I am having trouble running anything on my Android emulator and couldn't get hold of the Android device too. Approving best on my testing with the other plattforms.
|
@allgandalf Can you please resolve conflicts? |
|
@allgandalf Sorry more conflicts and Jest test failure (migth be flaky) |
|
on it |
…tals # Conflicts: # src/components/Search/SearchContext.tsx
|
🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.82-0 🚀
Bundle Size Analysis (Sentry): |
|
I reviewed the changes in this PR against all help site articles under No help site changes are required. This PR is an internal implementation change — it migrates the App to read freshly computed The existing help site articles that reference reimbursable totals — such as the @allgandalf, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
Deploy Blocker ##91729 was identified to be related to this PR. |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.82-3 🚀
|
|
Deploy Blocker #91755 was identified to be related to this PR. |
Explanation of Change
Frontend follow-up to https://github.com/Expensify/Auth/pull/20630, which started returning freshly computed
reimbursableTotal,unheldReimbursableTotal,nonReimbursableTotal,unheldNonReimbursableTotal, andunheldTotalon every report Onyx update.The original bug is that
report.total(the stored DB column) is sometimes stale and doesn't match the sum of the underlying transactions. Anywhere the App previously derived the user-facing reimbursable amount fromtotal - nonReimbursableTotalwould render the wrong value when the storedtotalwas out of date.This PR migrates the App to read the fresh fields directly:
reimbursableTotalandunheldReimbursableTotalto the Report Onyx type and the whitelisted report keys so they survive Onyx serialization.getMoneyRequestSpendBreakdownnow prefersreimbursableTotalover deriving it fromtotal - nonReimbursableTotal. This is the primary fix for the bug — it's whatMoneyReportView,MoneyRequestReportPreviewContent, search list items, and report previews all read.getNonHeldAndFullAmountnow prefersunheldReimbursableTotalfor the held-aware reimbursable display used by approve/pay buttons.populateOptimisticReportFormulauses the freshreimbursableTotalfield for the{report:reimbursable}template placeholder.PayMoneyRequest(both pay-amount derivation and cancel-payment optimistic action),Search.tspayment-amount and bulk-selection paths,IOU/index.tstest-receipt path, and thePayActionCellandTransactionItemRowUI cells now readreimbursableTotaldirectly.total/unheldTotal/nonReimbursableTotalto Onyx during optimistic updates also writesreimbursableTotal/unheldReimbursableTotalso the local state doesn't drift between the optimistic write and the next server response. CoversbuildOptimisticIOUReport,buildOptimisticExpenseReport,buildOptimisticEmptyReport,updateIOUOwnerAndTotal,IOU/index.tspolicy expense chat path,PerDiem.ts,RejectMoneyRequest.ts,Duplicate.ts,Report/index.tscurrency conversion path, andTransaction.tscross-report transaction moves.Every read also has a fallback to the legacy
total - nonReimbursableTotalderivation so older locally cached reports without the fresh field still display correctly.Fixed Issues
$ #80151
PROPOSAL: N/A
Tests
MoneyReportViewmatch the sum of the underlying expenses (reimbursable spend, non-reimbursable spend, total spend).Offline tests
QA Steps
MoneyReportViewmatch the sum of the underlying expenses.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