You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Expense - Duplicated expense does not redirect to report table view #94427
Version Number: 9.4.18-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#89585 Email or phone of affected tester (no customers): n/a Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Mac 15.4.1 Safari, Chrome, iPhone 13 iOS 26.5 App Component: Chat Report View
This is Scenario 3 of PR #89585 (merged 2026-06-23). That PR only touched RHP width and highlight logic — it made zero navigation changes — so it never actually addressed the "redirect to report table view" half of this scenario. The redirect is genuinely missing.
The view only flips chat→table when the RHP screen is mounted on the parent money‑request report via the table-capable SearchMoneyRequestReportPage (the EXPENSE_REPORT / SEARCH_MONEY_REQUEST_REPORT routes), where shouldDisplayReportTableView(report, transactions) becomes true once the report has >1 transaction.
But from Spend → Expenses, opening a single expense whose underlying report has >1 transaction resolves the target to the transaction‑threadchildReportID and navigates to ROUTES.SEARCH_REPORT (Search/index.tsx:540-548). That route renders ReportScreen, not the table page, and isReportTransactionThread is permanently true for a thread — so the table view can never appear, no matter how many transactions the parent gains.
When you then tap Duplicate expense, the handler simply calls duplicateTransaction([transaction]) with no navigation (MoneyRequestHeaderSecondaryActions.tsx:410-411; Duplicate.ts has no navigation at all). The duplicate row lands in the parent report's table — a screen the user is not on — so the RHP stays on the expense preview. Result: stays on the expense preview page.
Why Scenario 1 (single‑tx report) does work: there, the expense opens on the parent report, so duplicating bumps the displayed report's transactions.length 1→2 and the flip happens automatically. Scenario 3 fails precisely because the displayed report is a thread, not the parent — a count change can't trigger the flip.
What changes do you think we should make in order to solve the problem?
Add an explicit post‑duplicate redirect to the table-capable parent‑report route. In the DUPLICATE action's onSelected (MoneyRequestHeaderSecondaryActions.tsx:410-411), after duplicateTransaction([transaction]), when the underlying parent report will have >1 transaction, navigate to the parent report's table route — ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: parentReport.reportID}) (the route Search already uses for multi‑tx reports, which mounts SearchMoneyRequestReportPage → MoneyRequestReportView). parentReport is already available in that component. This mirrors the chat preview path, which opens the parent iouReportID on EXPENSE_REPORT_RHP and is why the flip works from chat.
What alternative solutions did you explore? (Optional)
Make the table-vs-preview decision follow a transaction thread up to its parent (so a thread route can render the table once the parent goes multi-tx). This is more invasive — it changes MoneyRequestReportView/SearchMoneyRequestReportPage to resolve the parent rather than the route's literal reportID — and risks regressing the intended single-expense preview behavior. The explicit redirect is the smaller, more targeted fix.
Confidence: High — two independent investigations agree, with file:line evidence. The flip is gated on the displayed report being the parent (not a thread); from Spend→Expenses the displayed report is the thread and no navigation fires, so the gate is never satisfied.
Note: No related duplicate issues were found in a quick open-issue scan. This is a fresh QA failure of PR #89585's Scenario 3.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/94427) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-06-24 08:13:36 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When you open a single expense from Spend → Expenses whose underlying report has more than one transaction and tap More → Duplicate expense, the RHP stays on the single‑expense preview instead of flipping to the report's table view (with the duplicate row highlighted and a super‑wide RHP). Scenarios where the source report has only one transaction (PR #89585 scenarios 1 & 2) work; this multi‑transaction‑source path (scenario 3) does not. Reproducible in production, so this is a pre‑existing gap, not a regression introduced by #89585.
What is the root cause of that problem?
The "flip to table" is driven only by the route report's own visible‑transaction count. In scenario 3 that route report is a single‑transaction thread report, and the duplicate never adds a transaction to it, so the gate can never become true.
Opening an expense from the Expenses list resolves the destination reportID. When the source is not a one‑transaction report, it is reassigned from the parent report to the IOU action's childReportID — the transaction thread report — which holds exactly one expense:
The page that renders the RHP decides table‑vs‑single purely from the route report's transactions: shouldShowSuperWideRHP = visibleTransactions.length > 1:
Duplicating builds the new expense on a freshly generated IOU report (optimisticIOUReportID = generateReportID()) in the active‑policy expense chat (targetReport: activePolicyExpenseChat) — i.e. not in the thread report being viewed — and performs no navigation and no markReportIDAsMultiTransactionExpense:
Substituting scenario 3 into the gate (step 4): the route report is the thread report → visibleTransactions.length stays 1 after duplication, and nothing optimistically marks that report multi‑transaction → useShowSuperWideRHPVersion(false) keeps the RHP at single‑expense width. That is exactly "stays on expense preview page." It's scenario‑3‑specific because only the non‑one‑transaction source path reassigns reportID to the thread (step 1); one‑transaction sources stay on the parent report and the gate flips naturally.
What changes do you think we should make in order to solve the problem?
After a successful duplicate, redirect to the destination report's table and optimistically widen it, reusing the exact mechanism Search/index.tsx already uses for multi‑transaction groups. In duplicateExpenseTransaction (useExpenseActions.ts) capture the destination report id (the optimisticIOUReportID the duplicate is built on, L231/L241) and, when the action originated from a single‑expense / transaction‑thread RHP, do:
markReportIDAsMultiTransactionExpense makes useShowSuperWideRHPVersion render super‑wide immediately (before the optimistic transaction count catches up), and the pendingNewTransactionIDs flag added in #89585 then fires the row highlight on that table. Regression safety: this runs only on the duplicate path from a single‑expense RHP, so the one‑transaction scenarios (already correct) and the report‑table scenario are untouched — the destination report is the same report the duplicate lands in.
Why the obvious one‑line fix fails: simply changing the gate to visibleTransactions.length >= 1, or only bumping markReportIDAsMultiTransactionExpense on the currently viewed report, does not work — the viewed thread report never receives the duplicate (step 4 creates it on a new optimisticIOUReportID), so its visible‑transaction count stays at 1 forever and the highlighted duplicate would not even live in that report. The redirect must target the destination report, not relax the count on the source thread.
What alternative solutions did you explore? (Optional)
Reassign less aggressively at the Search level — keep reportID as the parent report (don't jump to childReportID at Search/index.tsx#L546) so the RHP already shows the multi‑transaction table. Rejected: it changes the opening behavior for every multi‑transaction expense (you'd land on the table, not the single expense), which is the established UX and would regress the normal open flow.
Fire the redirect from SearchMoneyRequestReportPage by watching pendingNewTransactionIDs on the parent report and navigating to its table. Rejected as the headline: it adds per‑render watching on a page that renders for every expense and re‑derives the parent from the thread, whereas the destination report id is already known for free inside the duplicate action — cheaper and more direct to navigate there.
"Duplicate expense" from a single‑expense view never navigates anywhere, so the RHP stays on the source expense preview.
In the transaction‑thread header (the exact repro path: Spend → Expenses → open one expense → More → Duplicate expense), the DUPLICATE action's onSelected just fires the duplicate and returns — there is no navigation, and the result (which carries the report the duplicate landed in) is discarded:
Normal expense creation reaches the report/table view through navigateAfterExpenseCreate, but that runs in the confirmation flow. The duplicate path calls the action layer directly and bypasses confirmation, so no post‑create navigation runs.
The only thing inside requestMoney that could surface the new expense is the chat→table highlight rail, and it is gated by isOneToTwoTransactionTransition. That gate fails here for two independent reasons: the duplicate is created against the active‑policy chat report (so isMoneyRequestReport is false), and it requires the target to currently hold exactly one non‑deleted transaction — but the repro report already has more than one:
So even the highlight machinery never engages, and nothing redirects.
Crucially, the duplicate does not necessarily land in a brand‑new report. The wrapper passes targetReport: activePolicyExpenseChat and an optimisticIOUReportID, but noexistingIOUReport. getMoneyRequestInformation therefore falls back to chatReport.iouReportID and reuses the chat's existing open expense report when one exists — the optimisticIOUReportID is discarded in that case:
// STEP 2: Get the Expense/IOU report. If the existingIOUReport or moneyRequestReportID has been provided, we want to add the transaction to this specific report.
// If no such reportID has been provided, let's use the chatReport.iouReportID property. In case that is not present, build a new optimistic Expense/IOU report.
let iouReport: OnyxInputValue<OnyxTypes.Report> = null;
if (!iouReport || shouldCreateNewMoneyRequestReport) {
This is why the redirect must target the report ID the action actually returns, not the optimistic ID.
What changes do you think we should make in order to solve the problem?
After duplicating a single expense, navigate to the report that received the duplicate and open it as a multi‑transaction (super‑wide) table, mirroring exactly how Search opens a multi‑transaction report on row press — markReportIDAsMultiTransactionExpense(reportID) followed by navigation to the table‑capable SEARCH_MONEY_REQUEST_REPORT route:
The route choice matters. SEARCH_REPORT mounts the chat ReportScreen (loadRHPReportScreen) and can never show the table; the table page (SearchMoneyRequestReportPage → MoneyRequestReportView) is mounted only by EXPENSE_REPORT / SEARCH_MONEY_REQUEST_REPORT:
The IOU duplicateExpenseTransaction action returns {iouReport} from requestMoney — the report the transaction was actually written to (reused or newly built), already accounting for the chatReport.iouReportID reuse above:
So the fix is: in the wrapper, only for the single‑expense case (transactions.length === 1), capture the returned iouReport, then call markReportIDAsMultiTransactionExpense(iouReport.reportID) and Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: iouReport.reportID})). markReportIDAsMultiTransactionExpense (from useWideRHPActions) makes useShowSuperWideRHPVersion render super‑wide immediately, and the pendingNewTransactionIDs highlight added in #89585 then fires on that table.
The same gap exists in the report‑header variant, which should get the same treatment (or share a small helper):
Keep the navigation in these UI wrappers, not in the IOU action, since bulk/report duplication reuses the action and must not redirect per expense — hence the transactions.length === 1 guard.
What alternative solutions did you explore? (Optional)
Navigate to the wrapper's optimisticIOUReportID instead of the returned iouReport.reportID. Rejected: when the active‑policy expense chat already has an open expense report, getMoneyRequestInformation reuses chatReport.iouReportID and discards optimisticIOUReportID (MoneyRequestBuilder.ts:1324-1330), so the navigation would point at a report ID that was never created. Using the action's return value is correct in both the reuse and the brand‑new‑report cases.
Use the SEARCH_REPORT route after marking the report multi‑transaction. Rejected: SEARCH_REPORT mounts the chat ReportScreen, which has no table branch, so the view would never flip to the super‑wide table no matter how the report is marked.
Drop the isMoneyRequestReport/exactly‑one‑transaction gate so addPendingNewTransactionIDs covers duplicating into a multi‑transaction report. That restores the highlight, but on its own it still won't redirect from the single‑expense RHP — an explicit navigation to the target report is required either way.
Please re-state the problem that we are trying to solve in this issue.
When a user opens a single expense whose underlying report has more than one transaction and taps More → Duplicate expense, the UI stays on the expense preview page instead of switching to the report's table view. The duplicated row does not receive the highlight animation and the RHP is not set to super-wide width. The expected behaviour is that the view navigates to the report table, the new duplicate row is highlighted, and the RHP renders in super-wide mode.
What is the root cause of that problem?
The DUPLICATE_EXPENSE action handler in src/hooks/useExpenseActions.ts (line 364) calls duplicateExpenseTransaction([transaction]), which only fires the Onyx write action. After the call returns, none of the three post-duplication steps are performed:
markReportIDAsMultiTransactionExpense(reportID) is never called, so the RHP does not switch to super-wide mode.
addPendingNewTransactionIDs(reportID, newTransactionID) is never called, so the report metadata never records the new transaction ID as pending-new — meaning the highlight system in useNewTransactions has no fallback signal when the table view mounts.
Navigation.navigate to the report table route is never issued, so the user is left on the expense preview screen.
In contrast, the Search list's row-select handler in src/components/Search/index.tsx always calls markReportIDAsMultiTransactionExpense(reportID) before navigating to a multi-transaction report (lines 582–584), and other expense-create flows call addPendingNewTransactionIDs so the highlight animation works on first load via the pendingNewTransactionIDs fallback path in useNewTransactions. The navigation, RHP-width, and pending-transaction-metadata steps were never wired into the single-expense duplicate flow.
What changes do you think we should make in order to solve the problem?
src/libs/actions/IOU/Duplicate.ts — duplicateExpenseTransaction (around line 743): Return the newly created transaction ID(s) alongside the existing return value (or add them to the existing result object) so the caller in useExpenseActions.ts can pass the correct IDs to addPendingNewTransactionIDs and Navigation.navigate. For example:
// at the end of duplicateExpenseTransaction, include the new IDs in the return
return { ..., newTransactionIDs };
src/hooks/useExpenseActions.ts — duplicateExpenseTransaction wrapper (lines 226–260): After the duplicateTransactionAction loop completes, call addPendingNewTransactionIDs (imported from src/libs/actions/IOU/PendingNewTransactions) for each new transaction ID against the target report ID. This writes pendingNewTransactionIDs into Onyx report metadata so that when the table view mounts and useNewTransactions detects a 1→2 (or N→N+1) transition it can fall back to this metadata to identify which row to highlight:
import {addPendingNewTransactionIDs} from '@libs/actions/IOU/PendingNewTransactions';
// after duplicateTransactionAction loop:
for (const newTransactionID of newTransactionIDs) {
addPendingNewTransactionIDs(targetReportID, newTransactionID);
}
src/hooks/useExpenseActions.ts — same wrapper: Call markReportIDAsMultiTransactionExpense(targetReportID) from the WideRHPActionsContext (accessed via the existing useWideRHPActionsContext hook) to switch the RHP to super-wide mode before navigating, matching the behaviour in Search/index.tsx lines 582–584:
const {markReportIDAsMultiTransactionExpense} = useWideRHPActionsContext();
// after addPendingNewTransactionIDs calls:
markReportIDAsMultiTransactionExpense(targetReportID);
src/hooks/useExpenseActions.ts — same wrapper: Add Navigation.navigate to the report table route (e.g. ROUTES.SEARCH_REPORT.getRoute({reportID: targetReportID})) immediately after step 3, so the view switches to the report's table view after duplication.
src/hooks/useExpenseActions.ts — DUPLICATE_EXPENSEonSelected handler (around line 364): Verify that the targetReportID resolved in step 2 is forwarded correctly from the handler into the wrapper — it should be the activePolicyExpenseChat?.reportID or the optimisticIOUReportID produced by duplicateExpenseTransaction.
What alternative solutions did you explore? (Optional)
Instead of returning the new transaction IDs from duplicateExpenseTransaction and calling addPendingNewTransactionIDs in the hook layer, the pending-transaction registration and navigation could be placed entirely inside Duplicate.ts itself, mirroring how bulkDuplicateExpenses handles navigation — but keeping navigation and UI-state logic in the hook layer is cleaner and more consistent with how Search/index.tsx manages the same steps. The addPendingNewTransactionIDs call must still happen regardless of which layer owns navigation, because without it the highlight animation is lost whenever the table view's component tree fresh-mounts (the 1→2 transaction transition causes MoneyRequestReportActionsList to remount, breaking the diff-based detection that useNewTransactions normally relies on).
changed the title [-]Expense - Duplicated expense does not redirect to report table view[/-][+][$250] Expense - Duplicated expense does not redirect to report table view[/+]on Jun 24, 2026
When a user duplicates an expense from the single-expense preview (wide RHP on Spend → Expenses), the app only runs the create path (duplicateExpenseTransaction → requestMoney). It never runs the post-create navigation that normal expense submission uses.
Normal expense creation from the same preview goes through SubmitExpenseOrchestrator.handleReportInRHPDismiss, which calls dismissRHPToReport and navigates to SEARCH_MONEY_REQUEST_REPORT when the destination report already has transactions. Duplicate expense has no equivalent step, so the UI stays on the expense preview.
Highlighting is also incomplete: PR #89585 added pendingNewTransactionIDs in MoneyRequestBuilder and a small useNewTransactions tweak so the new row animates after navigation. That work was reverted in #94367, so even if we only add navigation, the duplicate row may not highlight reliably on the table.
What changes do you think we should make in order to solve the problem?
Only run when the user is in the expense RHP (isReportOpenInRHP).
If super-wide RHP is open, dismissToPreviousRHP (back to table).
If the destination report already has transactions, navigate to SEARCH_MONEY_REQUEST_REPORT.
Otherwise pop the RHP (single-tx report case).
Call it at the end of duplicateExpenseTransaction after createExpenseByType / trackExpense return, using result?.iouReport?.reportID.
Minimal sketch:
// Duplicate.ts — after createExpenseByType / trackExpense
const result = createExpenseByType({...});
navigateAfterDuplicateExpense(result?.iouReport?.reportID);
return result;
// navigateAfterDuplicateExpense.ts — core branch
if (!isReportOpenInRHP(rootState)) return;
if (hasExistingTransactions) {
Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID}));
}
2. Restore highlight metadata (partial re-apply of #89585)
In MoneyRequestBuilder.ts, write pendingNewTransactionIDs in optimistic data and clear it in success/failure data so useNewTransactions can highlight the new row after cross-navigation.
3. Fix useNewTransactions focus guard (partial re-apply of #89585)
In useNewTransactions.ts, remove the early isFocused === false return so the transaction diff can queue a highlight while the table view mounts. Keep the pendingNewTransactionIDs path gated by isFocused so unfocused chat previews do not consume the flag early.
What alternative solutions did you explore? (Optional)
Navigation in UI only (MoneyRequestHeaderSecondaryActions / useExpenseActions): Rejected because bulk duplicate and other entry points would miss the fix; the action layer already knows the destination iouReport.reportID.
Reuse handleNavigateAfterExpenseCreate: That helper is built for global-create / inbox flows, not "duplicate from expense preview in Search RHP."
Activity
applause-bot commentedon Jun 24, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/d7a1ed10ba65d13ac5586310c87f5e03a5309394bcf6cfdc9016f9c8ae7e754f
MelvinBot commentedon Jun 24, 2026
Proposal
What is the root cause of that problem?
This is Scenario 3 of PR #89585 (merged 2026-06-23). That PR only touched RHP width and highlight logic — it made zero navigation changes — so it never actually addressed the "redirect to report table view" half of this scenario. The redirect is genuinely missing.
The view only flips chat→table when the RHP screen is mounted on the parent money‑request report via the table-capable
SearchMoneyRequestReportPage(theEXPENSE_REPORT/SEARCH_MONEY_REQUEST_REPORTroutes), whereshouldDisplayReportTableView(report, transactions)becomestrueonce the report has >1 transaction.But from Spend → Expenses, opening a single expense whose underlying report has >1 transaction resolves the target to the transaction‑thread
childReportIDand navigates toROUTES.SEARCH_REPORT(Search/index.tsx:540-548). That route rendersReportScreen, not the table page, andisReportTransactionThreadis permanentlytruefor a thread — so the table view can never appear, no matter how many transactions the parent gains.When you then tap Duplicate expense, the handler simply calls
duplicateTransaction([transaction])with no navigation (MoneyRequestHeaderSecondaryActions.tsx:410-411;Duplicate.tshas no navigation at all). The duplicate row lands in the parent report's table — a screen the user is not on — so the RHP stays on the expense preview. Result: stays on the expense preview page.What changes do you think we should make in order to solve the problem?
Add an explicit post‑duplicate redirect to the table-capable parent‑report route. In the
DUPLICATEaction'sonSelected(MoneyRequestHeaderSecondaryActions.tsx:410-411), afterduplicateTransaction([transaction]), when the underlying parent report will have >1 transaction, navigate to the parent report's table route —ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: parentReport.reportID})(the route Search already uses for multi‑tx reports, which mountsSearchMoneyRequestReportPage→MoneyRequestReportView).parentReportis already available in that component. This mirrors the chat preview path, which opens the parentiouReportIDonEXPENSE_REPORT_RHPand is why the flip works from chat.What alternative solutions did you explore? (Optional)
Make the table-vs-preview decision follow a transaction thread up to its parent (so a thread route can render the table once the parent goes multi-tx). This is more invasive — it changes
MoneyRequestReportView/SearchMoneyRequestReportPageto resolve the parent rather than the route's literalreportID— and risks regressing the intended single-expense preview behavior. The explicit redirect is the smaller, more targeted fix.Investigation details & evidence
MoneyRequestHeaderSecondaryActions.tsx:364-414Duplicate.ts:743-876MoneyRequestReportView.tsx:161-162→shouldDisplayReportTableView/isSingleTransactionReportSEARCH_REPORT:Search/index.tsx:540-548SEARCH_REPORT→RHPReportScreen→ReportScreen(chat only, no table branch);EXPENSE_REPORT/SEARCH_MONEY_REQUEST_REPORT→SearchMoneyRequestReportPage(the only renderer ofMoneyRequestReportView):RightModalNavigator.tsx:433-456,SearchMoneyRequestReportPage.tsx:399-406iouReportIDonEXPENSE_REPORT_RHP(why the flip works from chat):MoneyRequestReportPreviewContent.tsx:516-536isReportTransactionThread/isOneTransactionReport:ReportUtils.ts:2742-2778Confidence: High — two independent investigations agree, with file:line evidence. The flip is gated on the displayed report being the parent (not a thread); from Spend→Expenses the displayed report is the thread and no navigation fires, so the gate is never satisfied.
Note: No related duplicate issues were found in a quick open-issue scan. This is a fresh QA failure of PR #89585's Scenario 3.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/94427)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
ahmdshrif commentedon Jun 24, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-24 08:13:36 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When you open a single expense from Spend → Expenses whose underlying report has more than one transaction and tap More → Duplicate expense, the RHP stays on the single‑expense preview instead of flipping to the report's table view (with the duplicate row highlighted and a super‑wide RHP). Scenarios where the source report has only one transaction (PR
#89585scenarios 1 & 2) work; this multi‑transaction‑source path (scenario 3) does not. Reproducible in production, so this is a pre‑existing gap, not a regression introduced by#89585.What is the root cause of that problem?
The "flip to table" is driven only by the route report's own visible‑transaction count. In scenario 3 that route report is a single‑transaction thread report, and the duplicate never adds a transaction to it, so the gate can never become true.
reportID. When the source is not a one‑transaction report, it is reassigned from the parent report to the IOU action'schildReportID— the transaction thread report — which holds exactly one expense:App/src/components/Search/index.tsx
Lines 540 to 548 in fc4f9e8
SEARCH_REPORT(wide, single‑expense RHP) — not as a multi‑transaction report:App/src/components/Search/index.tsx
Lines 629 to 635 in fc4f9e8
markReportIDAsMultiTransactionExpenseand routes toSEARCH_MONEY_REQUEST_REPORT:App/src/components/Search/index.tsx
Lines 582 to 597 in fc4f9e8
shouldShowSuperWideRHP = visibleTransactions.length > 1:App/src/pages/Search/SearchMoneyRequestReportPage.tsx
Lines 177 to 179 in fc4f9e8
optimisticIOUReportID = generateReportID()) in the active‑policy expense chat (targetReport: activePolicyExpenseChat) — i.e. not in the thread report being viewed — and performs no navigation and nomarkReportIDAsMultiTransactionExpense:App/src/hooks/useExpenseActions.ts
Lines 226 to 255 in fc4f9e8
Substituting scenario 3 into the gate (step 4): the route report is the thread report →
visibleTransactions.lengthstays1after duplication, and nothing optimistically marks that report multi‑transaction →useShowSuperWideRHPVersion(false)keeps the RHP at single‑expense width. That is exactly "stays on expense preview page." It's scenario‑3‑specific because only the non‑one‑transaction source path reassignsreportIDto the thread (step 1); one‑transaction sources stay on the parent report and the gate flips naturally.What changes do you think we should make in order to solve the problem?
After a successful duplicate, redirect to the destination report's table and optimistically widen it, reusing the exact mechanism
Search/index.tsxalready uses for multi‑transaction groups. InduplicateExpenseTransaction(useExpenseActions.ts) capture the destination report id (theoptimisticIOUReportIDthe duplicate is built on, L231/L241) and, when the action originated from a single‑expense / transaction‑thread RHP, do:markReportIDAsMultiTransactionExpensemakesuseShowSuperWideRHPVersionrender super‑wide immediately (before the optimistic transaction count catches up), and thependingNewTransactionIDsflag added in#89585then fires the row highlight on that table. Regression safety: this runs only on the duplicate path from a single‑expense RHP, so the one‑transaction scenarios (already correct) and the report‑table scenario are untouched — the destination report is the same report the duplicate lands in.Why the obvious one‑line fix fails: simply changing the gate to
visibleTransactions.length >= 1, or only bumpingmarkReportIDAsMultiTransactionExpenseon the currently viewed report, does not work — the viewed thread report never receives the duplicate (step 4 creates it on a newoptimisticIOUReportID), so its visible‑transaction count stays at 1 forever and the highlighted duplicate would not even live in that report. The redirect must target the destination report, not relax the count on the source thread.What alternative solutions did you explore? (Optional)
reportIDas the parent report (don't jump tochildReportIDat Search/index.tsx#L546) so the RHP already shows the multi‑transaction table. Rejected: it changes the opening behavior for every multi‑transaction expense (you'd land on the table, not the single expense), which is the established UX and would regress the normal open flow.SearchMoneyRequestReportPageby watchingpendingNewTransactionIDson the parent report and navigating to its table. Rejected as the headline: it adds per‑render watching on a page that renders for every expense and re‑derives the parent from the thread, whereas the destination report id is already known for free inside the duplicate action — cheaper and more direct to navigate there.lorretheboy commentedon Jun 24, 2026
Proposal
What is the root cause of that problem?
"Duplicate expense" from a single‑expense view never navigates anywhere, so the RHP stays on the source expense preview.
In the transaction‑thread header (the exact repro path: Spend → Expenses → open one expense → More → Duplicate expense), the
DUPLICATEaction'sonSelectedjust fires the duplicate and returns — there is no navigation, and the result (which carries the report the duplicate landed in) is discarded:App/src/components/MoneyRequestHeaderSecondaryActions.tsx
Lines 217 to 252 in fc4f9e8
Normal expense creation reaches the report/table view through
navigateAfterExpenseCreate, but that runs in the confirmation flow. The duplicate path calls the action layer directly and bypasses confirmation, so no post‑create navigation runs.The only thing inside
requestMoneythat could surface the new expense is the chat→table highlight rail, and it is gated byisOneToTwoTransactionTransition. That gate fails here for two independent reasons: the duplicate is created against the active‑policy chat report (soisMoneyRequestReportis false), and it requires the target to currently hold exactly one non‑deleted transaction — but the repro report already has more than one:App/src/libs/actions/IOU/PendingNewTransactions.ts
Lines 8 to 10 in fc4f9e8
App/src/libs/actions/IOU/TrackExpense.ts
Lines 1903 to 1928 in fc4f9e8
So even the highlight machinery never engages, and nothing redirects.
Crucially, the duplicate does not necessarily land in a brand‑new report. The wrapper passes
targetReport: activePolicyExpenseChatand anoptimisticIOUReportID, but noexistingIOUReport.getMoneyRequestInformationtherefore falls back tochatReport.iouReportIDand reuses the chat's existing open expense report when one exists — theoptimisticIOUReportIDis discarded in that case:App/src/libs/actions/IOU/MoneyRequestBuilder.ts
Lines 1321 to 1342 in fc4f9e8
This is why the redirect must target the report ID the action actually returns, not the optimistic ID.
What changes do you think we should make in order to solve the problem?
After duplicating a single expense, navigate to the report that received the duplicate and open it as a multi‑transaction (super‑wide) table, mirroring exactly how
Searchopens a multi‑transaction report on row press —markReportIDAsMultiTransactionExpense(reportID)followed by navigation to the table‑capableSEARCH_MONEY_REQUEST_REPORTroute:App/src/components/Search/index.tsx
Lines 581 to 602 in fc4f9e8
The route choice matters.
SEARCH_REPORTmounts the chatReportScreen(loadRHPReportScreen) and can never show the table; the table page (SearchMoneyRequestReportPage→MoneyRequestReportView) is mounted only byEXPENSE_REPORT/SEARCH_MONEY_REQUEST_REPORT:App/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx
Lines 433 to 456 in fc4f9e8
The IOU
duplicateExpenseTransactionaction returns{iouReport}fromrequestMoney— the report the transaction was actually written to (reused or newly built), already accounting for thechatReport.iouReportIDreuse above:App/src/libs/actions/IOU/Duplicate.ts
Lines 863 to 876 in fc4f9e8
App/src/libs/actions/IOU/TrackExpense.ts
Line 1614 in fc4f9e8
The thin UI wrapper today throws that return value away:
App/src/components/MoneyRequestHeaderSecondaryActions.tsx
Lines 217 to 252 in fc4f9e8
So the fix is: in the wrapper, only for the single‑expense case (
transactions.length === 1), capture the returnediouReport, then callmarkReportIDAsMultiTransactionExpense(iouReport.reportID)andNavigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: iouReport.reportID})).markReportIDAsMultiTransactionExpense(fromuseWideRHPActions) makesuseShowSuperWideRHPVersionrender super‑wide immediately, and thependingNewTransactionIDshighlight added in #89585 then fires on that table.The same gap exists in the report‑header variant, which should get the same treatment (or share a small helper):
App/src/hooks/useExpenseActions.ts
Lines 226 to 260 in fc4f9e8
Keep the navigation in these UI wrappers, not in the IOU action, since bulk/report duplication reuses the action and must not redirect per expense — hence the
transactions.length === 1guard.What alternative solutions did you explore? (Optional)
Navigate to the wrapper's
optimisticIOUReportIDinstead of the returnediouReport.reportID. Rejected: when the active‑policy expense chat already has an open expense report,getMoneyRequestInformationreuseschatReport.iouReportIDand discardsoptimisticIOUReportID(MoneyRequestBuilder.ts:1324-1330), so the navigation would point at a report ID that was never created. Using the action's return value is correct in both the reuse and the brand‑new‑report cases.Use the
SEARCH_REPORTroute after marking the report multi‑transaction. Rejected:SEARCH_REPORTmounts the chatReportScreen, which has no table branch, so the view would never flip to the super‑wide table no matter how the report is marked.Drop the
isMoneyRequestReport/exactly‑one‑transaction gate soaddPendingNewTransactionIDscovers duplicating into a multi‑transaction report. That restores the highlight, but on its own it still won't redirect from the single‑expense RHP — an explicit navigation to the target report is required either way.aswin-s commentedon Jun 24, 2026
Please re-state the problem that we are trying to solve in this issue.
When a user opens a single expense whose underlying report has more than one transaction and taps More → Duplicate expense, the UI stays on the expense preview page instead of switching to the report's table view. The duplicated row does not receive the highlight animation and the RHP is not set to super-wide width. The expected behaviour is that the view navigates to the report table, the new duplicate row is highlighted, and the RHP renders in super-wide mode.
What is the root cause of that problem?
The
DUPLICATE_EXPENSEaction handler insrc/hooks/useExpenseActions.ts(line 364) callsduplicateExpenseTransaction([transaction]), which only fires the Onyx write action. After the call returns, none of the three post-duplication steps are performed:markReportIDAsMultiTransactionExpense(reportID)is never called, so the RHP does not switch to super-wide mode.addPendingNewTransactionIDs(reportID, newTransactionID)is never called, so the report metadata never records the new transaction ID as pending-new — meaning the highlight system inuseNewTransactionshas no fallback signal when the table view mounts.Navigation.navigateto the report table route is never issued, so the user is left on the expense preview screen.In contrast, the Search list's row-select handler in
src/components/Search/index.tsxalways callsmarkReportIDAsMultiTransactionExpense(reportID)before navigating to a multi-transaction report (lines 582–584), and other expense-create flows calladdPendingNewTransactionIDsso the highlight animation works on first load via thependingNewTransactionIDsfallback path inuseNewTransactions. The navigation, RHP-width, and pending-transaction-metadata steps were never wired into the single-expense duplicate flow.What changes do you think we should make in order to solve the problem?
src/libs/actions/IOU/Duplicate.ts—duplicateExpenseTransaction(around line 743): Return the newly created transaction ID(s) alongside the existing return value (or add them to the existing result object) so the caller inuseExpenseActions.tscan pass the correct IDs toaddPendingNewTransactionIDsandNavigation.navigate. For example:src/hooks/useExpenseActions.ts—duplicateExpenseTransactionwrapper (lines 226–260): After theduplicateTransactionActionloop completes, calladdPendingNewTransactionIDs(imported fromsrc/libs/actions/IOU/PendingNewTransactions) for each new transaction ID against the target report ID. This writespendingNewTransactionIDsinto Onyx report metadata so that when the table view mounts anduseNewTransactionsdetects a 1→2 (or N→N+1) transition it can fall back to this metadata to identify which row to highlight:src/hooks/useExpenseActions.ts— same wrapper: CallmarkReportIDAsMultiTransactionExpense(targetReportID)from theWideRHPActionsContext(accessed via the existinguseWideRHPActionsContexthook) to switch the RHP to super-wide mode before navigating, matching the behaviour inSearch/index.tsxlines 582–584:src/hooks/useExpenseActions.ts— same wrapper: AddNavigation.navigateto the report table route (e.g.ROUTES.SEARCH_REPORT.getRoute({reportID: targetReportID})) immediately after step 3, so the view switches to the report's table view after duplication.src/hooks/useExpenseActions.ts—DUPLICATE_EXPENSEonSelectedhandler (around line 364): Verify that thetargetReportIDresolved in step 2 is forwarded correctly from the handler into the wrapper — it should be theactivePolicyExpenseChat?.reportIDor theoptimisticIOUReportIDproduced byduplicateExpenseTransaction.What alternative solutions did you explore? (Optional)
Instead of returning the new transaction IDs from
duplicateExpenseTransactionand callingaddPendingNewTransactionIDsin the hook layer, the pending-transaction registration and navigation could be placed entirely insideDuplicate.tsitself, mirroring howbulkDuplicateExpenseshandles navigation — but keeping navigation and UI-state logic in the hook layer is cleaner and more consistent with howSearch/index.tsxmanages the same steps. TheaddPendingNewTransactionIDscall must still happen regardless of which layer owns navigation, because without it the highlight animation is lost whenever the table view's component tree fresh-mounts (the 1→2 transaction transition causesMoneyRequestReportActionsListto remount, breaking the diff-based detection thatuseNewTransactionsnormally relies on).melvin-bot commentedon Jun 24, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Eskalifer1 (
External)[-]Expense - Duplicated expense does not redirect to report table view[/-][+][$250] Expense - Duplicated expense does not redirect to report table view[/+]melvin-bot commentedon Jun 24, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022069695146170062853
neerajbachani commentedon Jun 24, 2026
Proposal
What is the root cause of that problem?
When a user duplicates an expense from the single-expense preview (wide RHP on Spend → Expenses), the app only runs the create path (
duplicateExpenseTransaction→requestMoney). It never runs the post-create navigation that normal expense submission uses.Normal expense creation from the same preview goes through
SubmitExpenseOrchestrator.handleReportInRHPDismiss, which callsdismissRHPToReportand navigates toSEARCH_MONEY_REQUEST_REPORTwhen the destination report already has transactions. Duplicate expense has no equivalent step, so the UI stays on the expense preview.Highlighting is also incomplete: PR #89585 added
pendingNewTransactionIDsinMoneyRequestBuilderand a smalluseNewTransactionstweak so the new row animates after navigation. That work was reverted in #94367, so even if we only add navigation, the duplicate row may not highlight reliably on the table.What changes do you think we should make in order to solve the problem?
1. Add post-duplicate navigation (main fix)
Create
src/libs/Navigation/helpers/navigateAfterDuplicateExpense.tsthat mirrorsdismissRHPToReportfromsubmitDismissStrategies.ts:isReportOpenInRHP).dismissToPreviousRHP(back to table).SEARCH_MONEY_REQUEST_REPORT.Call it at the end of
duplicateExpenseTransactionaftercreateExpenseByType/trackExpensereturn, usingresult?.iouReport?.reportID.Minimal sketch:
2. Restore highlight metadata (partial re-apply of #89585)
In
MoneyRequestBuilder.ts, writependingNewTransactionIDsin optimistic data and clear it in success/failure data souseNewTransactionscan highlight the new row after cross-navigation.3. Fix
useNewTransactionsfocus guard (partial re-apply of #89585)In
useNewTransactions.ts, remove the earlyisFocused === falsereturn so the transaction diff can queue a highlight while the table view mounts. Keep thependingNewTransactionIDspath gated byisFocusedso unfocused chat previews do not consume the flag early.What alternative solutions did you explore? (Optional)
MoneyRequestHeaderSecondaryActions/useExpenseActions): Rejected because bulk duplicate and other entry points would miss the fix; the action layer already knows the destinationiouReport.reportID.handleNavigateAfterExpenseCreate: That helper is built for global-create / inbox flows, not "duplicate from expense preview in Search RHP."31 remaining items
melvin-bot commentedon Jul 3, 2026
@abzokhattab Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Jul 3, 2026
@abzokhattab Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
melvin-bot commentedon Jul 7, 2026
@abzokhattab 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
melvin-bot commentedon Jul 9, 2026
@abzokhattab 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
melvin-bot commentedon Jul 9, 2026
@abzokhattab 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
abzokhattab commentedon Jul 12, 2026
@blimpich should we close this issue, it looks to be duplciate to the already open issue here ... ref
melvin-bot commentedon Jul 15, 2026
@abzokhattab Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Jul 17, 2026
@abzokhattab Eep! 4 days overdue now. Issues have feelings too...
abzokhattab commentedon Jul 19, 2026
PR got merged .. we can close this one @blimpich