[Due for payment 2026-11-30] [$175] The expense confirmation screen shows an existing submitted report as the destination, but saving the expense silently creates a new report instead
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.4.93-3 Reproducible in staging?: Needs Reproduction Reproducible in production?: Needs Reproduction If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @Leeckhart Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
- Submit report, titled 9/21, so it is awaiting approval.
- From the workspace chat, tap the camera/photo option to scan and create a new cash expense.
- On the expense confirmation screen, confirm that the Report field displays the existing 9/21 report.
- Save the expense.
- Review the report where the expense was added.
Expected Result:
The expense should be added to the report displayed in the Report field. If a submitted report cannot accept new expenses, it should not appear as the selected destination, and the user should be told that a new report will be created.
Actual Result:
Although the confirmation screen displayed the 9/21 report, the app sent newly created report as the target. Report titled 9/21 was never passed during the save request. The customer then had to move the expense manually from the newly created report back to the intended report.
Note:
The issue appears to be caused by inconsistent eligibility logic: The Report field includes submitted reports that are awaiting first-level approval. The save logic only searches for an open/draft report. Therefore, the UI can display one report while the save action silently selects or creates another.
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [ ] Windows: Chrome
- [ ] MacOS: Chrome / Safari
Screenshots/Videos
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022105384062623167301
- Upwork Job ID: 2105384062623167301
- Last Price Increase: 2026-09-30
Issue Owner
Current Issue Owner: @ZhenjaHorbach
Proposal
What is the root cause of that problem?
The Report field and the save logic pick the default report using different rules.
When you submit 9/21, the workspace chat's iouReportID is cleared (ReportWorkflow.ts:1490-1502). Both sides then fall back to the submitter's outstanding reports:
- Report field (display):
ReportField.tsx:77-81takesgetOutstandingReportsForUser(..., false).at(0). That list still includes submitted reports that are awaiting first-level approval.isReportOutstandingaccepts them throughcanAddTransaction, which returns true throughisAwaitingFirstLevelApproval. So the field shows 9/21. - Save:
MoneyRequestBuilder.ts:1429-1435callsgetNewestOutstandingReportForUser. It adds.filter(isOpenExpenseReport), so 9/21 is rejected and a new optimistic report is built. This is intentional: see the doc comment atReportUtils.ts:12440-12443and the test "creates a new report when the submitter only has a report that is awaiting approval".
The Report field's pick is display-only. It is never written to transaction.reportID, so 9/21's ID is never sent in RequestMoney. If you pick 9/21 by hand in the picker, it works, because useReportSelectionActions.ts:195-202 writes the choice to the transaction.
What changes do you think we should make in order to solve the problem?
Make the Report field use the same default the save path uses:
- In
ReportField.tsx, replace theavailableOutstandingReports.at(0)fallback withgetNewestOutstandingReportForUser(...). When no open report exists, the field then shows "New report", which matches what gets created. - Better: move "default destination report" into one shared helper.
ReportField,MoneyRequestBuilderandPerDiem.ts:477-482should all call it. - Add a
ReportFieldtest: one submitted report awaiting first approval, no open report. The field should show "New report".
What alternative solutions did you explore? (Optional)
Remove the open-only filter so the expense goes into the submitted report. This reverses the intent of Reuse the submitter's outstanding report when the workspace chat has no iouReportID and its test, so it needs a product decision.
Investigation details
- History: Report can be selected on confirm page when expense cannot be added (2026-01-27) added the
canAddTransactionbranch toisReportOutstanding. After that, reports awaiting first-level approval appeared in the Report field fallback. Reuse the submitter's outstanding report when the workspace chat has no iouReportID (2026-09-16, in 9.4.93) added the open-only fallback on save. It changed only the sort order on the UI side, so the mismatch remained. - Second, smaller gap: when the chat's
iouReportIDis set, the field shows it without checks (ReportField.tsx:81). The save path still runsshouldCreateNewMoneyRequestReport, which forces a new report for scan requests when the ASAP-submit beta is on. The shared helper should apply that check too. - Likely repro conditions: the policy routes the report to a first-level approver (
submitsTo === managerID), the report hasn't been forwarded, and the policy isn't DEW (isAwaitingFirstLevelApproval). - Not verified: I haven't reproduced this in the app. The findings come from code reading at
ea6e334. I didn't find a likely duplicate among open issues.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/102688) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ZhenjaHorbach (External)
Job added to Upwork: https://www.upwork.com/jobs/~022105384062623167301
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user submits an expense report (e.g. titled "9/21") so that it is awaiting approval, and then creates a new scan/cash expense from the workspace chat, the confirmation screen displays the existing "9/21" report in the Report field. However, upon saving the expense, the app creates a brand new report instead of adding the transaction to "9/21".
What is the root cause of that problem?
When an expense report is submitted, the workspace chat report's iouReportID is cleared to undefined/null (src/libs/actions/IOU/ReportWorkflow.ts).
As a result, both the confirmation screen's ReportField UI and the save logic in MoneyRequestBuilder fall back to finding the submitter's outstanding reports:
- In
ReportField.tsx(lines 77-81):
const availableOutstandingReports = getOutstandingReportsForUser(policyID, ownerAccountID, rules, reportNameValuePairs, outstandingReportsForPolicy ?? {}, false).sort(
(report1, report2) => sortOutstandingReportsBySelected(report1, report2, undefined, localeCompare),
);
const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? availableOutstandingReports.at(0)?.reportID) : reportID;
getOutstandingReportsForUser(..., false) checks isReportOutstanding(report, policyID, rules, reportNameValuePairs, false).
Inside isReportOutstanding, even when allowSubmitted = false, it returns true if canAddTransaction(report) is true. canAddTransaction(report) returns true for reports awaiting first-level approval (isAwaitingFirstLevelApproval(report)).
Therefore, availableOutstandingReports includes the submitted "9/21" report, and availableOutstandingReports.at(0) selects it. ReportField displays "9/21".
- In
MoneyRequestBuilder.ts(lines 1429-1435):
if (!iouReport && isPolicyExpenseChat) {
iouReport = getNewestOutstandingReportForUser(chatReport.policyID, payeeAccountID, rules, getAllReportNameValuePairs(), allReports);
}
MoneyRequestBuilder calls getNewestOutstandingReportForUser(...) (src/libs/ReportUtils.ts:12449-12459).
getNewestOutstandingReportForUser explicitly applies .filter(isOpenExpenseReport):
const openReports = getOutstandingReportsForUser(policyID, reportOwnerAccountID, rules, reportNameValuePairs, reports, false).filter(isOpenExpenseReport);
Because the "9/21" report is submitted (not open), it is filtered out. If the user has no other open reports, getNewestOutstandingReportForUser returns null.
Then line 1453 executes:
if (!iouReport || shouldCreateNewMoneyRequestReport) {
iouReport = isPolicyExpenseChat ? buildOptimisticExpenseReport(...) : ...
Because transaction.reportID was not manually picked in IOURequestStepReport, moneyRequestReportID is undefined. The save flow creates a brand new report, silently diverging from what ReportField rendered on screen.
What changes do you think we should make in order to solve the problem?
The fallback report displayed in ReportField.tsx should use the exact same open report resolution as MoneyRequestBuilder:
- In
src/components/MoneyRequestConfirmationList/sections/ReportField.tsx:
- Import
getNewestOutstandingReportForUserfrom@libs/ReportUtils. - Replace the fallback
availableOutstandingReports.at(0)?.reportIDwithgetNewestOutstandingReportForUser(policyID, ownerAccountID, rules, reportNameValuePairs, outstandingReportsForPolicy ?? {})?.reportID:
--- a/src/components/MoneyRequestConfirmationList/sections/ReportField.tsx
+++ b/src/components/MoneyRequestConfirmationList/sections/ReportField.tsx
@@ -9,7 +9,7 @@ import Navigation from '@libs/Navigation/Navigation';
import Parser from '@libs/Parser';
import {getReportName} from '@libs/ReportNameUtils';
-import {generateReportID, getOutstandingReportsForUser, isMoneyRequestReport, isReportOutstanding, sortOutstandingReportsBySelected} from '@libs/ReportUtils';
+import {generateReportID, getNewestOutstandingReportForUser, getOutstandingReportsForUser, isMoneyRequestReport, isReportOutstanding, sortOutstandingReportsBySelected} from '@libs/ReportUtils';
import CONST from '@src/CONST';
@@ -78,7 +78,9 @@ function ReportField({iouType, reportID, reportActionID, action, transactionID,
(report1, report2) => sortOutstandingReportsBySelected(report1, report2, undefined, localeCompare),
);
- const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? availableOutstandingReports.at(0)?.reportID) : reportID;
+ const newestOutstandingReport = getNewestOutstandingReportForUser(policyID, ownerAccountID, rules, reportNameValuePairs, outstandingReportsForPolicy ?? {});
+ const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? newestOutstandingReport?.reportID) : reportID;
const [selectedReportID, selectedReport] = (() => {
const reportIDToUse = shouldUseTransactionReport ? transactionReportID : outstandingReportID;
@@ -95,6 +97,8 @@ function ReportField({iouType, reportID, reportActionID, action, transactionID,
reportToUse = mainReport;
} else if (reportIDToUse === iouReportIDFromMain) {
reportToUse = iouReport;
+ } else if (reportIDToUse === newestOutstandingReport?.reportID) {
+ reportToUse = newestOutstandingReport;
} else {
reportToUse = availableOutstandingReports.find((r) => r?.reportID === reportIDToUse);
}
Why this is the correct solution:
- When the workspace chat has no active
iouReportIDand the submitter only has submitted reports (awaiting approval),newestOutstandingReportcorrectly returnsnull.outstandingReportIDisundefined, soReportFielddisplays "New report" (translate('iou.newReport')). The confirmation screen accurately informs the user that a new report will be created. - If the user explicitly wants to attach the expense to the submitted report awaiting approval, they can tap the Report field to open the report picker (where
availableOutstandingReportsstill presents the submitted report since it can accept transactions manually). Selecting it setstransaction.reportID, makingshouldUseTransactionReporttrue, which both displays and saves to the chosen submitted report. - Zero regression for flows where the chat already has an open
iouReportIDor where an open expense report exists.
What alternative solutions did you explore? (Optional)
Change getNewestOutstandingReportForUser to include submitted reports awaiting approval. However, as documented in ReportUtils.ts:12440-12444, automatically dumping new expenses into a report that was already submitted for managerial review breaks the submission lifecycle and violates the test suite ("creates a new report when the submitter only has a report that is awaiting approval").
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0170d6b02e9440e604
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user submits an expense report (e.g. titled "9/21") such that it is awaiting approval, and then initiates a new cash or scan expense from the workspace chat, the confirmation screen displays the existing "9/21" report in the Report field. However, upon saving the expense, the application creates a brand new report instead of attaching the transaction to the "9/21" report displayed on screen.
What is the root cause of that problem?
There is an architectural mismatch in fallback report resolution between the confirmation UI (ReportField.tsx) and the transaction persistence builder (MoneyRequestBuilder.ts):
-
In
ReportField.tsx(lines 77-84):const availableOutstandingReports = getOutstandingReportsForUser(policyID, ownerAccountID, rules, reportNameValuePairs, outstandingReportsForPolicy ?? {}, false).sort( (report1, report2) => sortOutstandingReportsBySelected(report1, report2, undefined, localeCompare), ); const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? availableOutstandingReports.at(0)?.reportID) : reportID;When a report has been submitted for approval, the workspace chat's
iouReportIDis cleared toundefined.ReportFieldfalls back toavailableOutstandingReports.at(0)?.reportID.getOutstandingReportsForUser(..., false)checksisReportOutstanding(report, ...)which in turn checkscanAddTransaction(report). BecausecanAddTransactionreturnstruefor reports awaiting first-level approval (isAwaitingFirstLevelApproval(report)), the submitted "9/21" report is included inavailableOutstandingReports. Consequently,ReportFielddisplays the submitted "9/21" report as the default destination. -
In
src/libs/actions/IOU/MoneyRequestBuilder.ts(lines 1429-1435 & 1453):if (!iouReport && isPolicyExpenseChat) { iouReport = getNewestOutstandingReportForUser(chatReport.policyID, payeeAccountID, rules, getAllReportNameValuePairs(), allReports); }When the user saves without manually interacting with the report picker,
moneyRequestReportIDisundefined.MoneyRequestBuildertherefore falls back togetNewestOutstandingReportForUser(...). InsidegetNewestOutstandingReportForUser(src/libs/ReportUtils.ts:12457), it explicitly applies:const openReports = getOutstandingReportsForUser(policyID, reportOwnerAccountID, rules, reportNameValuePairs, reports, false).filter(isOpenExpenseReport);Because the "9/21" report is in
SUBMITTEDstate (not open),isOpenExpenseReportfilters it out.getNewestOutstandingReportForUserreturnsnull. Line 1453 then triggers:if (!iouReport || shouldCreateNewMoneyRequestReport) { iouReport = isPolicyExpenseChat ? buildOptimisticExpenseReport(...) : ... }This creates a brand new report, directly conflicting with the "9/21" report shown to the user on the confirmation screen.
What changes do you think we should make in order to solve the problem?
Align the fallback report resolution in ReportField.tsx with MoneyRequestBuilder.ts by using getNewestOutstandingReportForUser:
-
In
src/components/MoneyRequestConfirmationList/sections/ReportField.tsx:- Import
getNewestOutstandingReportForUserfrom@libs/ReportUtils. - Update
outstandingReportIDresolution so that the automatic fallback in policy expense chats selectsnewestOutstandingReport?.reportIDrather thanavailableOutstandingReports.at(0)?.reportID:
--- a/src/components/MoneyRequestConfirmationList/sections/ReportField.tsx +++ b/src/components/MoneyRequestConfirmationList/sections/ReportField.tsx @@ -9,7 +9,7 @@ import Navigation from '@libs/Navigation/Navigation'; import Parser from '@libs/Parser'; import {getReportName} from '@libs/ReportNameUtils'; -import {generateReportID, getOutstandingReportsForUser, isMoneyRequestReport, isReportOutstanding, sortOutstandingReportsBySelected} from '@libs/ReportUtils'; +import {generateReportID, getNewestOutstandingReportForUser, getOutstandingReportsForUser, isMoneyRequestReport, isReportOutstanding, sortOutstandingReportsBySelected} from '@libs/ReportUtils'; import CONST from '@src/CONST'; @@ -78,7 +78,9 @@ function ReportField({iouType, reportID, reportActionID, action, transactionID, (report1, report2) => sortOutstandingReportsBySelected(report1, report2, undefined, localeCompare), ); - const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? availableOutstandingReports.at(0)?.reportID) : reportID; + const newestOutstandingReport = getNewestOutstandingReportForUser(policyID, ownerAccountID, rules, reportNameValuePairs, outstandingReportsForPolicy ?? {}); + const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? newestOutstandingReport?.reportID) : reportID; const [selectedReportID, selectedReport] = (() => { const reportIDToUse = shouldUseTransactionReport ? transactionReportID : outstandingReportID; @@ -95,6 +97,8 @@ function ReportField({iouType, reportID, reportActionID, action, transactionID, reportToUse = mainReport; } else if (reportIDToUse === iouReportIDFromMain) { reportToUse = iouReport; + } else if (reportIDToUse === newestOutstandingReport?.reportID) { + reportToUse = newestOutstandingReport; } else { reportToUse = availableOutstandingReports.find((r) => r?.reportID === reportIDToUse); } - Import
-
User Experience & Contract Consistency:
- When a user only has submitted reports awaiting approval,
newestOutstandingReportreturnsundefined.outstandingReportIDisundefined, soReportFielddisplaystranslate('iou.newReport')("New report"). The UI accurately informs the user that a new report will be created upon save. - If the user explicitly wishes to add the expense to the submitted report awaiting approval, they can tap the Report field to open the report picker (where
availableOutstandingReportsstill presents the submitted report becausecanAddTransaction(report)is true). Selecting it setstransaction.reportID, makingshouldUseTransactionReporttrue, which both displays and successfully persists to the chosen submitted report.
- When a user only has submitted reports awaiting approval,
Automated Tests
- Unit Test in
ReportField.test.tsx:- Verify that when the user has only submitted expense reports awaiting approval and no open reports,
ReportFieldrenders "New report" as the default destination. - Verify that when an open expense report exists alongside submitted reports,
ReportFielddefaults to the newest open report.
- Verify that when the user has only submitted expense reports awaiting approval and no open reports,
- Integration Test in
MoneyRequestBuilderTest.ts:- Verify that saving an expense without an explicit report selection when only submitted reports exist generates a new report and matches what was presented on the confirmation screen.
What alternative solutions did you explore? (Optional)
Changing MoneyRequestBuilder (and getNewestOutstandingReportForUser) to automatically dump expenses into submitted reports awaiting approval. This was rejected because automatically injecting unexpected expenses into a report that was already submitted for manager approval violates the approval workflow lifecycle and contradicts established test suites in ReportUtilsTest ("creates a new report when the submitter only has a report that is awaiting approval").
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Thread: https://expensify.slack.com/archives/C049HHMV9SM/p1790775102714569
@MelvinBot it was hard to repro this, but it has something to do with switching to the Inbox tab.
- Go to Spend
- Create an expense
- Submit the report
- Click the camera button > take a picture
- Observe the report row reads
Report: New report:white_check_mark: - Exit the flow
- Go to the Workspaces tab
- Click the camera button > take a picture
- Observe the report row reads
Report: New report:white_check_mark: - Go to the Account tab
- Click the camera button > take a picture
- Observe the report row reads
Report: New report:white_check_mark: - Go to the Inbox tab
- Click the camera button > take a picture
- Observe the report row reads
Report: <the report you submitted in step 3>:x:
Thanks trjExpensify, those steps explain it. Inbox is the only tab where the confirmation screen loads the workspace chat in the background. That fresh chat data is what makes the Report row pick the submitted report.
Why only Inbox: The camera button and the scan flow work the same on every tab. The difference comes when the confirmation screen opens on a narrow (mobile) layout. To speed up the screen you land on after saving, the app quietly opens that screen behind the confirmation (getSubmitExpensePreMountDestinationRoute.ts:65-78):
- Inbox: opens the workspace chat behind the confirmation. Mounting that chat calls
OpenReport(ReportFetchHandler.tsx:541-550). - Workspaces / Account: opens Search instead. No
OpenReporton the chat. - Spend: Search is already on top, so nothing opens.
When the OpenReport response lands, the Report row recalculates. Its default (ReportField.tsx:81) doesn't check that the report is open. It accepts reports awaiting first approval, so it shows the submitted report. The save path only reuses open reports (ReportUtils.ts:12467-12477), so it creates a new report.
Fix: The earlier proposal still applies. Make the Report row use the same default as the save path, so the background OpenReport can't change what the row shows. The regression test should cover a flow started from Inbox on a narrow layout.
Investigation details
- Entry point is the same on every tab: the camera button always calls
startMoneyRequest(CREATE, <workspace chat>, SCAN)(BaseFloatingCameraButton.tsx:77-95). After capture, the flow sets the same participants and reportID on every tab (NavigateGlobalCreateContext.tsx:99-132). - How the issue started: [Performance] Migrate submit-expense flow to
usePreMountDestination(merged 2026-07-24) added the background chat mount that only happens from Inbox. Reuse the submitter's outstanding report when the workspace chat has no iouReportID (merged 2026-09-16) made the save path open-only. It also sorted the Report row's list newest-first, so the report you just submitted now comes first. - Not confirmed: I can't tell from App code which field in the
OpenReportresponse flips the row. It could be the chat'siouReportIDor the report'smanagerID/state, which decides "awaiting first approval". Either way, the fix above covers it. Submitting from the Spend list doesn't setmanagerIDor clear the chat'siouReportIDlocally (Search.ts:1582-1590). So the local data beforeOpenReportcan differ from what the server returns. - Not reproduced: these findings come from reading code at
8249fbf, not from running the app. The background chat mount happens only on narrow layouts, so a wide desktop browser may not reproduce this.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/102688#issuecomment-5918469012) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Proposal for Issue #102688
Title: The expense confirmation screen shows an existing submitted report as the destination, but saving the expense silently creates a new report instead
Please re-state the problem that we are trying to solve in this issue.
In New Expensify, when an expense report has just been submitted, initiating an expense creation or receipt scan from the Inbox tab (via floating camera or FAB) causes the confirmation screen to display the previously submitted report under the Report field (e.g. Report: [Submitted Report Name]). However, upon saving the expense, the application silently creates a brand-new report instead of attaching the expense to the displayed report. Conversely, performing the exact same flow from other tabs (Spend, Workspaces, Account) correctly displays Report: New report.
What is the root cause of that problem?
-
Background Workspace Chat Mount via
usePreMountDestinationon Inbox tab: On narrow layouts, navigating to the expense creation flow from the Inbox tab mounts the workspace chat in the background to pre-warm the post-submission destination (getSubmitExpensePreMountDestinationRoute.ts:65-78). This triggersOpenReporton the workspace chat (ReportFetchHandler.tsx:541-550), updatingmainReport.iouReportIDin Onyx with the ID of the recently submitted IOU report. -
Unvalidated Fallback on
iouReportIDFromMaininReportField.tsx: Insrc/components/MoneyRequestConfirmationList/sections/ReportField.tsx(lines 72–81):const transactionReportNameValuePair = reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${transactionReportID}`]; const shouldUseTransactionReport = (!!transactionReportEntry && isReportOutstanding(transactionReportEntry, policyID, rules, transactionReportNameValuePair, false)) || isUnreported; const ownerAccountID = selectedParticipants?.at(0)?.ownerAccountID; const availableOutstandingReports = getOutstandingReportsForUser(policyID, ownerAccountID, rules, reportNameValuePairs, outstandingReportsForPolicy ?? {}, false).sort( (report1, report2) => sortOutstandingReportsBySelected(report1, report2, undefined, localeCompare), ); const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? availableOutstandingReports.at(0)?.reportID) : reportID;Notice that while
availableOutstandingReports(line 77) andshouldUseTransactionReport(line 73) strictly passallowSubmitted = falsetogetOutstandingReportsForUserandisReportOutstandingto ensure submitted reports are excluded,iouReportIDFromMain(mainReport?.iouReportID) is consumed unconditionally without checkingisReportOutstanding(..., false). -
Divergence from Expense Save Path: When saving the expense, the save logic (
requestMoney/IOU.ts) only attaches transactions to open reports (isOpenReport(report)). Because the submitted report is inSUBMITTED/PROCESSINGstate, the save path discards it and generates a new report, diverging completely from whatReportFieldpromised the user.
What changes do you think we should make in order to solve the problem?
In src/components/MoneyRequestConfirmationList/sections/ReportField.tsx:
Validate iouReport against isReportOutstanding with allowSubmitted = false before selecting iouReportIDFromMain:
const iouReportNameValuePair = reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReportIDFromMain}`];
const isIouReportOutstanding = !!iouReport && isReportOutstanding(iouReport, policyID, rules, iouReportNameValuePair, false);
const outstandingReportID = isPolicyExpenseChat ? ((isIouReportOutstanding ? iouReportIDFromMain : undefined) ?? availableOutstandingReports.at(0)?.reportID) : reportID;
When iouReport has been submitted (or is otherwise not open/outstanding):
isIouReportOutstandingevaluates tofalse.outstandingReportIDskipsiouReportIDFromMainand falls back toavailableOutstandingReports.at(0)?.reportID.- If no other open report exists for the policy, it resolves to
undefined, which generates a new report ID and correctly rendersReport: New reportinReportField. - This guarantees that
ReportFielddisplays the exact destination report that the save path will attach the expense to across all tabs.
What alternative solutions did you explore? (Optional)
- Suppressing
usePreMountDestinationon the Inbox tab: Rejected because background pre-mounting is a deliberate performance optimization to eliminate post-submit transition lag. - Clearing
mainReport.iouReportIDin Onyx on report submission: Rejected becauseiouReportIDon the chat report is maintained by the backend to identify the active transaction thread / IOU report for chat action routing.
Contributor Details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01ff3c252bcc7ad776
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0170d6b02e9440e604
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user submits an expense report (e.g. titled "9/21") such that it is awaiting approval, and then initiates a new cash or scan expense from the workspace chat, the confirmation screen displays the existing "9/21" report in the Report field. However, upon saving the expense, the application creates a brand new report instead of attaching the transaction to the "9/21" report displayed on screen.
What is the root cause of that problem?
There is an architectural mismatch in fallback report resolution between the confirmation UI (ReportField.tsx) and the transaction persistence builder (MoneyRequestBuilder.ts):
-
In
ReportField.tsx(lines 77-84):const availableOutstandingReports = getOutstandingReportsForUser(policyID, ownerAccountID, rules, reportNameValuePairs, outstandingReportsForPolicy ?? {}, false).sort( (report1, report2) => sortOutstandingReportsBySelected(report1, report2, undefined, localeCompare), ); const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? availableOutstandingReports.at(0)?.reportID) : reportID;When a report has been submitted for approval, the workspace chat's
iouReportIDis cleared toundefined.ReportFieldfalls back toavailableOutstandingReports.at(0)?.reportID.getOutstandingReportsForUser(..., false)checksisReportOutstanding(report, ...)which in turn checkscanAddTransaction(report). BecausecanAddTransactionreturnstruefor reports awaiting first-level approval (isAwaitingFirstLevelApproval(report)), the submitted "9/21" report is included inavailableOutstandingReports. Consequently,ReportFielddisplays the submitted "9/21" report as the default destination. -
In
src/libs/actions/IOU/MoneyRequestBuilder.ts(lines 1429-1435 & 1453):if (!iouReport && isPolicyExpenseChat) { iouReport = getNewestOutstandingReportForUser(chatReport.policyID, payeeAccountID, rules, getAllReportNameValuePairs(), allReports); }When the user saves without manually interacting with the report picker,
moneyRequestReportIDisundefined.MoneyRequestBuildertherefore falls back togetNewestOutstandingReportForUser(...). InsidegetNewestOutstandingReportForUser(src/libs/ReportUtils.ts:12457), it explicitly applies:const openReports = getOutstandingReportsForUser(policyID, reportOwnerAccountID, rules, reportNameValuePairs, reports, false).filter(isOpenExpenseReport);Because the "9/21" report is in
SUBMITTEDstate (not open),isOpenExpenseReportfilters it out.getNewestOutstandingReportForUserreturnsnull. Line 1453 then triggers:if (!iouReport || shouldCreateNewMoneyRequestReport) { iouReport = isPolicyExpenseChat ? buildOptimisticExpenseReport(...) : ... }This creates a brand new report, directly conflicting with the "9/21" report shown to the user on the confirmation screen.
What changes do you think we should make in order to solve the problem?
Align the fallback report resolution in ReportField.tsx with MoneyRequestBuilder.ts by using getNewestOutstandingReportForUser:
-
In
src/components/MoneyRequestConfirmationList/sections/ReportField.tsx:- Import
getNewestOutstandingReportForUserfrom@libs/ReportUtils. - Update
outstandingReportIDresolution so that the automatic fallback in policy expense chats selectsnewestOutstandingReport?.reportIDrather thanavailableOutstandingReports.at(0)?.reportID:
--- a/src/components/MoneyRequestConfirmationList/sections/ReportField.tsx +++ b/src/components/MoneyRequestConfirmationList/sections/ReportField.tsx @@ -9,7 +9,7 @@ import Navigation from '@libs/Navigation/Navigation'; import Parser from '@libs/Parser'; import {getReportName} from '@libs/ReportNameUtils'; -import {generateReportID, getOutstandingReportsForUser, isMoneyRequestReport, isReportOutstanding, sortOutstandingReportsBySelected} from '@libs/ReportUtils'; +import {generateReportID, getNewestOutstandingReportForUser, getOutstandingReportsForUser, isMoneyRequestReport, isReportOutstanding, sortOutstandingReportsBySelected} from '@libs/ReportUtils'; import CONST from '@src/CONST'; @@ -78,7 +78,9 @@ function ReportField({iouType, reportID, reportActionID, action, transactionID, (report1, report2) => sortOutstandingReportsBySelected(report1, report2, undefined, localeCompare), ); - const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? availableOutstandingReports.at(0)?.reportID) : reportID; + const newestOutstandingReport = getNewestOutstandingReportForUser(policyID, ownerAccountID, rules, reportNameValuePairs, outstandingReportsForPolicy ?? {}); + const outstandingReportID = isPolicyExpenseChat ? (iouReportIDFromMain ?? newestOutstandingReport?.reportID) : reportID; const [selectedReportID, selectedReport] = (() => { const reportIDToUse = shouldUseTransactionReport ? transactionReportID : outstandingReportID; @@ -95,6 +97,8 @@ function ReportField({iouType, reportID, reportActionID, action, transactionID, reportToUse = mainReport; } else if (reportIDToUse === iouReportIDFromMain) { reportToUse = iouReport; + } else if (reportIDToUse === newestOutstandingReport?.reportID) { + reportToUse = newestOutstandingReport; } else { reportToUse = availableOutstandingReports.find((r) => r?.reportID === reportIDToUse); } - Import
-
User Experience & Contract Consistency:
- When a user only has submitted reports awaiting approval,
newestOutstandingReportreturnsundefined.outstandingReportIDisundefined, soReportFielddisplaystranslate('iou.newReport')("New report"). The UI accurately informs the user that a new report will be created upon save. - If the user explicitly wishes to add the expense to the submitted report awaiting approval, they can tap the Report field to open the report picker (where
availableOutstandingReportsstill presents the submitted report becausecanAddTransaction(report)is true). Selecting it setstransaction.reportID, makingshouldUseTransactionReporttrue, which both displays and successfully persists to the chosen submitted report.
- When a user only has submitted reports awaiting approval,
Automated Tests
- Unit Test in
ReportField.test.tsx:- Verify that when the user has only submitted expense reports awaiting approval and no open reports,
ReportFieldrenders "New report" as the default destination. - Verify that when an open expense report exists alongside submitted reports,
ReportFielddefaults to the newest open report.
- Verify that when the user has only submitted expense reports awaiting approval and no open reports,
- Integration Test in
MoneyRequestBuilderTest.ts:- Verify that saving an expense without an explicit report selection when only submitted reports exist generates a new report and matches what was presented on the confirmation screen.
What alternative solutions did you explore? (Optional)
Changing MoneyRequestBuilder (and getNewestOutstandingReportForUser) to automatically dump expenses into submitted reports awaiting approval. This was rejected because automatically injecting unexpected expenses into a report that was already submitted for manager approval violates the approval workflow lifecycle and contradicts established test suites in ReportUtilsTest ("creates a new report when the submitter only has a report that is awaiting approval").
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Contributor Details
- Contributor:
@tuananh4865 - Email:
[email protected] - Upwork:
https://www.upwork.com/freelancers/~0146a4de0ca9fff602?companyReference=2103308912547901160&mp_source=share
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates an expense or scans a receipt from the Inbox tab after submitting an expense report (e.g. "9/21"), the confirmation screen shows that submitted report as the destination (Report: 9/21). When the user taps Create expense, the app silently creates a new report instead of adding the expense to "9/21".
The same flow from Spend, Workspaces or Account correctly shows Report: New report.
The confirmation UI therefore promises one destination and the save logic delivers another, and the behavior differs by entry point.
What is the root cause of that problem?
The confirmation UI and the save path use different rules to pick the default report, and the Inbox tab feeds the UI a value that only the UI trusts.
1. The Inbox tab hydrates iouReportID in the background.
On mobile and narrow layouts, usePreMountDestination (getSubmitExpensePreMountDestinationRoute.ts:65-78) pre-mounts the workspace chat. That triggers OpenReport and populates mainReport.iouReportID in Onyx with the most recently submitted report's ID. The other tabs don't pre-mount the chat, so the value isn't populated there and they fall through to "New report".
2. ReportField trusts that value without validating it.
In ReportField.tsx (~line 81):
const outstandingReportID = isPolicyExpenseChat
? (iouReportIDFromMain ?? availableOutstandingReports.at(0)?.reportID)
: reportID;
iouReportIDFromMain (mainReport?.iouReportID) is used as the default without checking that the report is still open (isOpenExpenseReport(iouReport)) or that it can take a new default expense. A submitted report awaiting approval passes through.
The fallback has the same flaw. availableOutstandingReports comes from getOutstandingReportsForUser(..., false), and isReportOutstanding returns true whenever canAddTransaction(iouReport) is true. A submitted report awaiting approval is therefore still in the list, and .at(0) can pick it. That is correct for the manual picker but wrong as an automatic default.
3. The save path applies stricter rules.
In MoneyRequestBuilder.ts (~lines 1428-1453):
- For scan requests with the ASAP-submit beta, or when there is no
iouReport,shouldCreateNewMoneyRequestReportistrue, so a new report is created. - For non-scan requests, the default comes from
getNewestOutstandingReportForUser, which filters with.filter(isOpenExpenseReport). A submitted report is never chosen.
So the save logic never defaults to a submitted report, while ReportField can display one. The UI should derive its default with the same rule the save path uses.
What changes do you think we should make in order to solve the problem?
The change is confined to src/components/MoneyRequestConfirmationList/sections/ReportField.tsx. It makes the displayed default follow the same eligibility rule as the save path.
1. Imports
import {getNewestOutstandingReportForUser, isOpenExpenseReport, /* existing imports */} from '@libs/ReportUtils';
2. Validate iouReport before using iouReportIDFromMain, and fall back to the same helper the save path uses
const isIouReportEligible = !!iouReport && isOpenExpenseReport(iouReport);
const newestOutstandingReport = getNewestOutstandingReportForUser(
policyID,
ownerAccountID,
rules,
reportNameValuePairs,
outstandingReportsForPolicy ?? {},
);
const fallbackReportID = isIouReportEligible ? iouReportIDFromMain : newestOutstandingReport?.reportID;
const outstandingReportID = isPolicyExpenseChat ? fallbackReportID : reportID;
The arguments mirror what MoneyRequestBuilder passes to getNewestOutstandingReportForUser. I'll reuse the data already available in the component, or the same useOnyx selectors the builder relies on, rather than introducing new sources. Replacing availableOutstandingReports.at(0) with getNewestOutstandingReportForUser is what guarantees display and save agree.
3. Resolve selectedReport for the new fallback source
const [selectedReportID, selectedReport] = (() => {
const reportIDToUse = shouldUseTransactionReport ? transactionReportID : outstandingReportID;
if (!reportIDToUse) {
return [generateReportID(), undefined] as const;
}
let reportToUse: OnyxEntry<OnyxTypes.Report> | undefined;
if (reportIDToUse === transactionReportID) {
reportToUse = transactionReportEntry;
} else if (reportIDToUse === reportID) {
reportToUse = mainReport;
} else if (reportIDToUse === iouReportIDFromMain) {
reportToUse = iouReport;
} else if (reportIDToUse === newestOutstandingReport?.reportID) {
reportToUse = newestOutstandingReport;
} else {
reportToUse = availableOutstandingReports.find((r) => r?.reportID === reportIDToUse);
}
return [reportIDToUse, reportToUse ?? undefined] as const;
})();
Resulting behavior
| Scenario | Displayed Report |
Saved to |
|---|---|---|
| Only a submitted report (e.g. 9/21), no open report, from any tab | New report | New report |
| An open report and a submitted report | The open report | The open report |
| Non-policy-expense chat (1:1) | Unchanged (reportID branch) |
Unchanged |
| User taps the field and picks the submitted report | The picked report | The picked report |
- When the user only has submitted reports awaiting approval,
outstandingReportIDisundefined.reportNamethen renderstranslate('iou.newReport'), which is identical across Inbox, Spend, Workspaces and Account. - Manual selection is preserved. The picker still lists the submitted report because
availableOutstandingReportsis unchanged andcanAddTransaction(report)is true. Selecting it setstransaction.reportID, which makesshouldUseTransactionReporttrue, so the field both displays and persists the chosen submitted report. isPolicyExpenseChatis false for 1:1 chats, so that branch still usesreportIDand is untouched.
Test cases
- Create and submit report "9/21". From the Inbox tab, tap the camera and scan a receipt. The Report field shows New report, and saving creates a new report without touching "9/21".
- Repeat step 1 with manual expense creation from Inbox, and from Spend, Workspaces and Account. All four show New report.
- With an open report and a submitted report in the same workspace, the Report field defaults to the open report and saving adds the expense to it.
- In a non-policy expense chat (1:1), confirmation behavior is unchanged.
- Tap the Report field, select the submitted report "9/21", and save. The expense is added to "9/21".
- Add unit tests for
ReportField's default resolution in two cases. In the first,iouReportis submitted and no open report exists, so the result isundefined. In the second,iouReportis open, so the result is its ID.
What alternative solutions did you explore? (Optional)
-
Make the save path attach the expense to the submitted report to match the UI. Rejected. Submitted reports awaiting approval are not valid automatic destinations, and the existing
isOpenExpenseReportfilter ingetNewestOutstandingReportForUseris intentional. Silently adding expenses to a report under review would be a worse product behavior than the current display bug. -
Stop pre-mounting the workspace chat in
usePreMountDestinationon Inbox. Rejected. The pre-mount exists for navigation performance. Removing it regresses that and only hides the symptom for this one entry point, so any other path that hydratesiouReportIDwould show the same bug. -
Filter submitted reports out of
availableOutstandingReportsglobally. Rejected. It would remove the user's ability to deliberately choose a submitted report in the picker, which is a supported flow. The fix should only change the automatic default. -
Clear or ignore
mainReport.iouReportIDon the Inbox path. Rejected. The field is valid data used elsewhere, and the real defect is thatReportFieldconsumes it without the eligibility check.
Follow-up (out of scope): the ASAP-submit scan path in MoneyRequestBuilder forces shouldCreateNewMoneyRequestReport to true. If the UI should show "New report" for that beta even when an open report exists, that is a separate parity item. It would be worth verifying with the beta enabled, but it is not required to fix the reported issue.
@ZhenjaHorbach Eep! 4 days overdue now. Issues have feelings too...
Please
Don't post proposals when an issue doesn't have Help Wanted label
@MelvinBot Implement your proposal
🤖 Draft PR created: Make the confirmation Report field show the report the expense is saved to Please mark it as "Ready for review" or ask me to do that for you when it is ready for review.
The Report field now picks its default with the same helpers the save path uses (getNewestOutstandingReportForUser and shouldCreateNewMoneyRequestReport). When saving would create a new report, the field shows "New report" instead of the submitted report. This also covers the Inbox case: whatever the background OpenReport loads, the field can only show a report that saving would use.
Details
- Changed:
ReportField.tsxand its transaction selector, which now passesisScanRequest. A manual pick of a submitted report still works. - Tests: a new
ReportField.test.tsxhas 4 cases. Three fail without the fix, and all four pass with it. The related confirmation-list andGetMoneyRequestInformationTestsuites pass (66 tests). Typecheck, lint, spelling, and React Compiler checks pass. - Not done: I didn't reproduce the Inbox flow in the app. The
TestsandQAsections of the PR are left for the human co-author.
Deploy Blocker https://github.com/Expensify/App/issues/105073 was identified to be related to the PR https://github.com/Expensify/App/pull/103361 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.
Deploy Blocker https://github.com/Expensify/App/issues/105074 was identified to be related to the PR https://github.com/Expensify/App/pull/103361 that attempted to fix this issue.