Fix duplicate report blockers: preserve negative amounts and handle deleted workspaces#86098
Conversation
…eleted workspaces Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
@hungvu193 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❌ 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.
|
|
on it 👀 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9f4dd4fc1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const targetPolicyForDuplicate = policy ?? defaultExpensePolicy; | ||
| const targetChatForDuplicate = policy ? chatReport : activePolicyExpenseChat; | ||
| const isSourcePolicyValid = !!policy && isPolicyAccessible(policy, currentUserLogin ?? ''); | ||
| const targetPolicyForDuplicate = isSourcePolicyValid ? policy : defaultExpensePolicy; |
There was a problem hiding this comment.
Preserve distance/per-diem rows when rerouting deleted-workspace copies
When policy is inaccessible we now reroute the duplicate into defaultExpensePolicy, which makes duplicateReport() treat every deleted-workspace copy as cross-workspace. In src/libs/actions/IOU/Duplicate.ts:846-847, cross-workspace duplication drops all distance and per-diem transactions, so a deleted-workspace report containing those expenses will still duplicate as an empty/partial report instead of preserving its contents. This only affects deleted-workspace reports with distance or per-diem items, but it leaves that workflow broken.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I tried to find a reason for the logic below, but it seems really weird and I couldn’t find any references. @hungvu193 Do you remember anything about this?
App/src/libs/actions/IOU/Duplicate.ts
Lines 846 to 848 in 5f7e6bc
cc: @Valforte
There was a problem hiding this comment.
I guess when it's cross workspace, they have different rate, mileage/custom units...etc, so you filtered it out? @Krishna2323
There was a problem hiding this comment.
I think so but can't recall 😭
There was a problem hiding this comment.
That filter makes sense with what @hungvu193 commented. There's also the issue that Per diem, distance and time can be disable in the workspace. What happens if the user tries to duplicate and there are different rates? Will the original rate be used or the rate of the target workspace? If it's the second I believe we can allow the duplication.
|
@Krishna2323 Can you check this one? Bug: "Duplicate expense" does nothing with Expense that has pending deleted transaction:
Screen.Recording.2026-03-23.at.21.21.29.mov |
|
@hungvu193 I think that isn't related to the PR, the single duplicate feature was buggy even before the implementation. |
|
@Krishna2323 Please check the AI comment then we're good to go 👍 |
|
@hungvu193 could you please check this comment? |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-03-23.at.21.18.11.movScreen.Recording.2026-03-23.at.21.30.22.mov |
…t creation Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
🚧 @Valforte 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! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Fix duplicate report blockers: preserve negative amounts and handle deleted workspaces (cherry picked from commit 39d4768) (cherry-picked to staging by francoisl)
|
🚀 Cherry-picked to staging by https://github.com/francoisl in version: 9.3.42-1 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to production by https://github.com/grgia in version: 9.3.42-3 🚀
|
Explanation of Change
Fixed Issues
$ #82153
$ #86093
$ #86095
PROPOSAL:
Tests
Same as QA Steps
Verify that no errors appear in the JS console
Offline tests
QA Steps
Test 1:
Test 2:
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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
Monosnap.screencast.2026-03-23.19-01-14.mp4