Fix: Reuse Submit workspace Draft expense report for additional expenses#92141
Fix: Reuse Submit workspace Draft expense report for additional expenses#92141MelvinBot wants to merge 2 commits into
Conversation
…sactions canAddTransaction's isPaidGroupPolicy check excludes Submit2026 policies, so the second expense on a Submit workspace builds a new optimistic report instead of reusing the existing Draft. Use isGroupPolicy (which covers Submit + paid) so a Draft expense report on a Submit workspace can accept additional transactions. Co-authored-by: Hans <hungvu193@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: git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-submitDraftReportReuse
git checkout -b claude-submitDraftReportReuse upstream/claude-submitDraftReportReuse
git push -u origin claude-submitDraftReportReuseThen you can close this PR and open a new one from your fork. |
ReportSecondaryActionUtilsTest, ReportPreviewActionUtilsTest, and RequestMoneyTest mocked isPaidGroupPolicy but not isGroupPolicy. Now that canAddTransaction calls isGroupPolicy, these tests need the matching mock. Co-authored-by: Hans <hungvu193@users.noreply.github.com>
|
Fixed the failing tests: the PR switched The remaining |
|
@MelvinBot Add these steps for QA steps also complete the Author checklist: Sign up for an account |
|
Updated the PR body with the QA steps you provided (mirrored into the Tests section as well) and checked off the Author Checklist. Let me know if anything needs to be tweaked. |
Explanation of Change
On a Submit workspace, creating a second expense from Spend or Global Create produced a new Draft report instead of landing on the existing Draft.
The root cause is in
canAddTransaction()(src/libs/ReportUtils.ts). It gates whether an existing expense report can receive additional transactions, and required the report's policy to satisfyisPaidGroupPolicy— which istrueonly forTEAM/CORPORATEpolicies and excludes Submit (POLICY.TYPE.SUBMIT === 'submit2026').That
falsepropagated intoshouldCreateNewMoneyRequestReport(), which forced the expense builder to create a brand-new optimistic expense report each time instead of reusing the existing Draft.The fix uses
PolicyUtils.isGroupPolicy(policy)(imported asisGroupPolicyPolicyUtils), which already treats Submit and paid (Team/Corporate) workspaces uniformly — its doc comment explicitly calls out this case. This is a one-line behavioral change plus a one-line import.Unit-test mocks for
PolicyUtils.isGroupPolicyare added so the threecanAddTransaction-dependent tests intests/unit/ReportUtilsTest.tsexercise the new code path.Fixed Issues
$ #91994
PROPOSAL: #91994 (comment)
Tests
Offline tests
Same as the Tests steps above, performed with the network disabled — the second expense should still attach to the existing Draft report optimistically.
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