Fix empty expense preview after reverse-split offline delete#88021
Fix empty expense preview after reverse-split offline delete#88021
Conversation
When deleting one of two split expense children while offline (triggering a reverse-split), the expense preview rendered empty after going back online. Three issues in the reverse-split path of updateSplitTransactions: 1. existingTransaction was set to undefined, causing getMoneyRequestInformation to skip fastMerge with the original transaction data. 2. currentReportActionID was undefined, creating a duplicate IOU action instead of reusing the existing firstIOU. 3. No failure data existed to restore the original transaction or firstIOU on API failure. Co-authored-by: truph01 <truph01@users.noreply.github.com>
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.
|
|
@MelvinBot Please make sure you implemented all the fixes mentioned here:
|
… path Add success data to clear pendingAction on the firstIOU report action after API success in the reverse-split path, matching the pattern used in DeleteMoneyRequest.ts. Also include childMoneyRequestCount in the report preview failure data so it gets restored on API failure. Co-authored-by: truph01 <truph01@users.noreply.github.com>
|
Reviewed the three fixes from the proposal and found two were missing. Pushed a fix (2c19c2d):
What was added:
|
| newNonReimbursableTotal: (transactionReport?.nonReimbursableTotal ?? 0) - changesInReportTotal, | ||
| isSplitExpense: true, | ||
| currentReportActionID: !isReverseSplitOperation ? currentReportAction?.reportActionID : undefined, | ||
| currentReportActionID: !isReverseSplitOperation ? currentReportAction?.reportActionID : firstIOU?.reportActionID, |
There was a problem hiding this comment.
@MelvinBot, Why do we need this change? It caused an BE error when calling RevertSplitTransaction
There was a problem hiding this comment.
You're right — reverted in 038924c.
The intent was to fix the "duplicate IOU action" described in the proposal (passing undefined causes getMoneyRequestInformation to generate a fresh reportActionID via rand64() at ReportUtils.ts:7224, creating a new IOU action instead of reusing firstIOU). But passing firstIOU?.reportActionID causes that ID to flow through to splitReportActionID (at Split.ts:1502) and get sent to the RevertSplitTransaction backend API, which doesn't expect an already-existing action ID.
Reverted back to undefined. The duplicate IOU action issue from the proposal likely needs a server-side fix or a different client-side approach (e.g., cleaning up the duplicate in success/failure data rather than preventing its creation).
The reverse-split path must pass undefined as currentReportActionID so getMoneyRequestInformation generates a new reportActionID via rand64(). Passing firstIOU.reportActionID caused the optimistic IOU action to reuse the existing action's ID, which was then sent as splitReportActionID to the RevertSplitTransaction backend API, causing an error. Co-authored-by: truph01 <truph01@users.noreply.github.com>
|
@MelvinBot Mark this PR as ready for review |
|
Done — this PR is now marked as ready for review. 👍 |
Explanation of Change
When deleting one of two split expense children while offline (triggering a reverse-split via
REVERT_SPLIT_TRANSACTION), the expense preview rendered empty after going back online.Three issues in the reverse-split path of
updateSplitTransactionsinSplit.ts:existingTransactionwas set toundefined— This causedgetMoneyRequestInformationto skipfastMergewith the original transaction data, so the restored transaction lost all fields from the pre-split original.currentReportActionIDwasundefined— This created a duplicate IOU action instead of reusing the existingfirstIOU, leaving two IOU actions for the sameoriginalTransactionIDafter the server responded.No failure data existed to restore the original transaction to its pre-split state (with
reportID: SPLIT_REPORT_ID) or restorefirstIOUon API failure. Compare to the non-reverse-split path which properly handles both.Fixed Issues
$ #87065
Tests
// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
Offline tests
QA Steps
// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review".
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