[$175] Duplicating an expense should stay on the source report when that report can accept it
Problem
Duplicating an expense ignores the report you are looking at. The duplicate is routed to your default workspace, then to whatever report that workspace chat's iouReportID points at — usually the most recently created report from that chat. If you duplicate an expense while viewing an open, editable report, the copy can land on a different report or on a brand-new one.
That is surprising. People duplicate an expense to get a second copy here, next to the original.
Current behavior
- useExpenseActions.ts builds the duplicate with
targetPolicy: defaultExpensePolicyandtargetReport: getPolicyExpenseChat(accountID, defaultExpensePolicy.id)— the default expense policy, not the source expense's policy. - Duplicate.ts passes that workspace chat to
requestMoney, and MoneyRequestBuilder.ts resolves the target asallReports[`report_${chatReport.iouReportID}`]— one pointer, no list, no sorting. With two draft reports on the workspace, the second is never considered. shouldCreateNewMoneyRequestReportthen forces a new report when that pointer is missing, pending delete, or cannot accept transactions — so a third draft can appear instead of reusing an addable one.
Proposed behavior
When the source expense is already on a report and that report can accept the duplicate, target the source report. Fall back to today's default-workspace routing only when it cannot.
Roughly: pass the source expense's reportID (and its policy) as the explicit target when the source report is open or otherwise addable — reuse the same "can this report accept a transaction" check shouldCreateNewMoneyRequestReport already relies on, instead of adding a second definition.
Cases to cover
- Source report is submitted, approved, closed, or pending delete → keep current behavior, do not reopen a locked report.
- Source expense has no report (self-DM / tracked) → stays unreported, as today.
- Source report belongs to a workspace other than your default → the duplicate should follow the source report, not jump workspaces.
Related
- Expensify/App#99395 — new expense lands on a new report instead of the existing draft (manual-create path, same routing gap).
Reported in Slack.
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022108295391114710662
- Upwork Job ID: 2108295391114710662
- Last Price Increase: 2026-10-08
Issue Owner
Current Issue Owner: @thelullabyy
Triggered auto assignment to Contributor-plus team member for initial proposal review - @thelullabyy (External)
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
@thelullabyy Eep! 4 days overdue now. Issues have feelings too...
@thelullabyy Still overdue 6 days?! Let's take care of this!
@thelullabyy Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!
@MelvinBot Please investigate and drop proposal
Proposal
Please re-state the problem that we are trying to solve in this issue.
Duplicating an expense while viewing an open expense report puts the copy on a different report, or a new one. It should stay on the report you are viewing.
What is the root cause of that problem?
Both "Duplicate expense" entry points always target the default workspace chat, never the source report:
- The report header (
useExpenseActions.ts:280-282) passestargetPolicy: defaultExpensePolicyandtargetReport: activePolicyExpenseChat. - The expense thread header (
MoneyRequestHeaderSecondaryActions.tsx:295-297) does the same.
When the target is a chat, MoneyRequestBuilder.ts:1421-1432 picks whatever chatReport.iouReportID points to. If that report can't take the expense, shouldCreateNewMoneyRequestReport creates a new one.
The action layer already supports a specific report. If report is an expense report, requestMoney sets moneyRequestReportID to it (TrackExpense.ts:1741-1743). The distance and per diem paths do the same. This is how "Add expense" inside a report works. The hooks just never pass the source report.
What changes do you think we should make in order to solve the problem?
Choose the target in the two hooks. Duplicate.ts needs no changes.
-
Add
canDuplicateIntoSourceReporttouseExpenseActionsandMoneyRequestHeaderSecondaryActions. It is true when all of these hold:- the source report is an expense report and is not archived
- its chat report is loaded and not archived
- its policy is accessible (the same check "Duplicate report" uses)
!shouldCreateNewMoneyRequestReport(sourceReport, chatReport, false, isASAPSubmitBetaEnabled, rules, CONST.IOU.ACTION.CREATE, true)
Reusing
shouldCreateNewMoneyRequestReport(it wrapscanAddTransaction) means the hook and the builder always agree. No second "addable" definition is needed. -
If true, use the source report and its policy as the target. Otherwise keep the default workspace chat and default policy.
-
Point everything that depends on the target at the chosen policy and report: categories, tags,
policyTagList, participants, and billing restriction checks. -
Compare the per diem cross-workspace block (
useExpenseActions.ts:230) against the target policy, not the default one. -
Close the menu when the copy lands on the viewed report: OR the new flag into
shouldDuplicateCloseModalOnSelect.
This covers each case in the issue:
- Submitted, approved, closed, or pending-delete source: the check fails, so routing stays as it is today.
- Self-DM or tracked source: there is no expense report, so the copy stays unreported through
trackExpense. - Source on a non-default workspace: the copy follows the source report and policy.
Tests:
- In
tests/actions/IOUTest/DuplicateTest.ts, pass an open expense report astargetReport. Assert thatREQUEST_MONEYuses that report'siouReportID. - Add a
useExpenseActionshook test withDuplicatemocked. An open source report should target itself. An approved source report should fall back to the default chat.
What alternative solutions did you explore? (Optional)
- Pass
existingIOUReportinstead: this skips the one-to-two-expenses handling thatrequestMoneyruns when it gets a report. - Apply the same routing to bulk duplicate in the report selection toolbar: its
iouReportIDpatching inDuplicate.tsassumes the target is a chat, so it's better handled as a follow-up.
Related issue
[Due for payment 2026-09-24] [Exploratory] Expense report- Create new expense added to new report instead of current draft report (closed) has the same routing gap in the manual create path.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/101327) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
@thelullabyy Whoops! This issue is 2 days overdue. Let's get this updated quick!
@thelullabyy Eep! 4 days overdue now. Issues have feelings too...
@thelullabyy Huh... This is 4 days overdue. Who can take care of this?
@MelvinBot Please open PR based on your proposal. Let's double check again if any other changes needed as well
🤖 Draft PR created: Keep duplicated expenses on the source report when it can accept them Please mark it as "Ready for review" when it is ready for review.
The PR follows the proposal. I checked again for other changes and found two small ones beyond the proposal:
- Shared check: both entry points need the same "can the source report take the copy" rule. I put it in one helper,
canDuplicateExpenseIntoSourceReportinReportUtils, instead of copying it into each hook. It wrapsshouldCreateNewMoneyRequestReport. - Thread header categories and tags:
MoneyRequestHeaderSecondaryActionssubscribed to the default workspace's categories and tags. It now subscribes to the target workspace's.
I confirmed no other changes are needed:
- The distance path (
createDistanceRequest) and the per diem path (submitPerDiemExpense) already add to a given expense report. SoDuplicate.tsstays unchanged. - Visibility of the duplicate action in
ReportSecondaryActionUtilsdoesn't depend on the target. - Bulk duplicate (
useBulkDuplicateAction) still uses the default workspace chat. It's left for a follow-up, as the proposal says.
Local checks
typecheck,lint-changed,spell-changed, andoxfmtpassed.- The React Compiler check passed on both changed files.
- Jest: 1,532 tests passed across
ReportUtilsTest,DuplicateTest, and the related header and hook suites, including the new tests. - The automated web UI check didn't run. The test browser crashed during onboarding, before reaching the duplicate flow. A manual test is still needed.
view run · no recording available
Job added to Upwork: https://www.upwork.com/jobs/~022108295391114710662
Triggered auto assignment to @francoisl, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Duplicating an expense always sends the copy to the default workspace's latest report (or a new one), even when the expense's own report is open and could take it.
What is the root cause of that problem?
Each duplicate entry point picks its own target, and all three hard-code the default workspace chat:
- the report header: useExpenseActions.ts#L282
- the expense thread header: MoneyRequestHeaderSecondaryActions.tsx#L298
- bulk duplicate: useBulkDuplicateAction.ts#L94
duplicateExpenseTransaction then hands that chat to the create flow, which uses whatever report chatReport.iouReportID points to, or makes a new one. Nothing ever looks at where the source expense lives. Because the choice is copied across three callers, fixing only some of them would leave bulk duplicate behaving differently from single duplicate.
The create flow already supports adding to a specific expense report. It's what "Add expense" inside a report uses. The callers just never pass the source report.
What changes do you think we should make in order to solve the problem?
-
One pure helper for "where should this copy go?" Add getDuplicateExpenseTarget({sourceReport, sourceChatReport, sourcePolicy, defaultPolicy, defaultPolicyExpenseChat, …}) next to the other duplicate helpers. It returns {targetReport, targetPolicy}:
- Source report is an expense report that can take the copy: return the source report and its policy. "Can take it" means the report and its chat aren't archived, the policy is accessible, and shouldCreateNewMoneyRequestReport(…) returns false, so it reuses the existing rule instead of defining a second one.
- Source report is submitted, approved, closed or pending delete: return today's default workspace target.
- Unreported or Self DM expense: return today's behavior, so the copy stays unreported.
The helper only takes data as arguments, which makes it easy to unit test.
-
Use it in all three entry points, including bulk duplicate. For bulk, work out the target for each selected expense. Selections from a single report then all land on that report, and a selection from Search that spans reports sends each copy to its own source report.
-
Use the target workspace's categories and tags, not the default workspace's. Otherwise a copy on another workspace's report gets checked against the wrong category and tag lists.
-
No changes to Duplicate.ts, which already accepts any target report.
-
Tests:
- helper cases: open report, submitted report, approved report, archived report, pending-delete report, a report on another workspace, and an unreported expense
- a bulk duplicate test where expenses from two open reports each land on their own report
What alternative solutions did you explore? (Optional)
Changing the target only in the two single-expense headers. That fixes the reported case, but bulk duplicate would still send every copy to the default workspace. The same action would then put copies in different places depending on how many expenses were selected.
Contributor details Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~010efadac9ff3c3d2a/
Deploy Blocker https://github.com/Expensify/App/issues/103866 was identified to be related to the PR https://github.com/Expensify/App/pull/103072 that attempted to fix this issue.
⚠️ Looks like this issue was linked to a Deploy Blocker here
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.
If a regression has occurred and you are the assigned CM follow the instructions here.
If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.
@thelullabyy
The solution for this issue has been :rocket: deployed to production :rocket: in version 9.5.8-5 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
- https://github.com/Expensify/App/pull/103072
If no regressions arise, payment will be issued on 2026-10-21. :confetti_ball:
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
@thelullabyy Whoops! This issue is 2 days overdue. Let's get this updated quick!
Triggered auto assignment to @mallenexpensify (Awaiting Payment)