Preserve GPS distance properties when reverting a split expense#84633
Preserve GPS distance properties when reverting a split expense#84633
Conversation
When a GPS distance split is reverted, the optimistic transaction was missing commentType and customUnit because existingTransaction was set to undefined. This caused isDistanceRequest/isGPSDistanceRequest to return false, making the Distance and Amount fields incorrectly editable. Pass commentType from the original transaction through the reverse split path, and broaden the customUnit setup condition in buildOptimisticTransaction to also enter the block when customUnit is explicitly provided as a parameter. Co-authored-by: Roji Philip <rojiphil@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
|
The failing check ( Analysis: The full-repo ESLint check is failing with 336 warnings (0 errors) in files not touched by this PR. The "Changed files ESLint check" (which only lints files modified in this PR) passes successfully. The warnings are in these unrelated files:
Evidence: This PR only modifies |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@MelvinBot Close this PR as the issue is no longer reproducible |
|
Closing this PR as requested by |
Explanation of Change
When a GPS distance split is reverted (by deleting one of the splits), the optimistic transaction created during the revert was missing
commentTypeandcustomUnitproperties. This happened because the reverse split path inSplit.tssetsexistingTransactiontoundefined, causingbuildOptimisticTransactionto skip settingcomment.typetoCUSTOM_UNITandcomment.customUnit. Without these properties,isDistanceRequest()andisGPSDistanceRequest()returnfalse, making the Distance and Amount fields incorrectly editable.Two changes fix this:
commentTypefrom the original transaction through the reverse split path (matching the existing pattern in the edit draft path).customUnitsetup condition inbuildOptimisticTransactionto also enter the block whencustomUnitis explicitly provided as a parameter, even without anexistingTransaction.Fixed Issues
$ #82635
PROPOSAL: #82635 (comment)
Tests
Offline tests
QA Steps
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