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
[$175] A failed move to another report is undone silently and leaves an empty $0 report #106962
When a move of an expense to another report fails, the expense goes back to its old report. The app shows no error, and an empty $0 report stays behind.
changed the title [-]A failed move to another report is undone silently and leaves an empty $0 report[/-][+][$175] A failed move to another report is undone silently and leaves an empty $0 report[/+]on Nov 16, 2026
Medium confidence: Failed moves restore the expense without adding a fallback error. Separately, creating the destination and moving the expense are independent requests, so a failed move does not undo successful report creation.
Code evidence and limitations
Silent rollback:Transaction.ts:1212–1224 restores the original report association without attaching an error.
Empty destination: Move failure restores the destination’s previous totals/count in Transaction.ts:1870–1916, rather than deleting the independently created report.
Alternative checked: Server responses can supply their own errors through onyxData; therefore, not every rejection is necessarily silent (OnyxUpdates.ts:74–111).
These findings explain the reported symptoms when creation succeeds and the subsequent move fails without a server-supplied error. They do not establish why the move was rejected. Production logs were unavailable, the reported ~170 failures/day was not independently verified, and no browser reproduction was performed.
What changes do you think we should make in order to solve the problem?
Escalate the complete fix to an internal engineer for server-side lifecycle review. The required behavior is a visible failure on the restored expense plus safe, persistent cleanup of a destination created exclusively for that failed move.
An App-only removal from local state would hide, not delete, a persisted report. Existing report deletion can also unreport transactions, and its inspected request has no “only if still empty” guard (Report/index.ts:7548–7561, 7939–7946). Guaranteed cleanup therefore needs backend coordination, not an unverified App-only deletion.
Validation should cover successful creation followed by failed movement, existing destinations, concurrent additions, successful retry, and persistence after reload.
What alternative solutions did you explore? (Optional)
Deleting every empty destination is unsafe: it may predate the move or have acquired other content. A visible error alone addresses the silent rollback but leaves the empty-report symptom unresolved.
Next Steps for Contributor+ team:
Internal engineering review is required before accepting implementation. To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/106962) to create a draft PR once an App-scoped plan is confirmed. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
There are two distinct root causes contributing to this behavior:
Silent transaction move failure:
In src/libs/actions/Transaction.ts (changeTransactionsReport, lines 1212–1225), when the ChangeTransactionsReport API command fails, failureData reverts the transaction's reportID, comment, and currency/amount values back to their pre-move state:
Unlike other money request mutations (e.g. changeTransactionsToAutomaticReport in Transaction.ts:2290 or UpdateMoneyRequest.ts), failureData does not set errors on the transaction object. Therefore, when the server rejects the move request, the expense is moved back to the original report with zero visual feedback or Red Brick Road (RBR) indicator.
Empty destination report lingering after rollback:
When moving an expense via the "Create report" option (createReportForPolicy in src/pages/iou/request/step/IOURequestStepReport/hooks/useReportPickerActions.ts:220–239), an optimistic report is created via createNewReport (WRITE_COMMANDS.CREATE_APP_REPORT), followed immediately by changeTransactionsReport (WRITE_COMMANDS.CHANGE_TRANSACTIONS_REPORT).
In Transaction.ts:1870–1916, failureData reverts the destination report's total, unheldTotal, and transactionCount. However, because the destination report itself was optimistically generated for this move, rolling back the totals leaves an empty, unlinked report with $0 total in Onyx (ONYXKEYS.COLLECTION.REPORT) and the LHN/search views, instead of cleaning it up as done for selfDMReport in Transaction.ts:1038–1055.
What changes do you think we should make in order to solve the problem?
Surface error on the transaction upon move failure:
In src/libs/actions/Transaction.ts inside changeTransactionsReport:
In optimisticData, set errors: null on each moving transaction to clear any previous transient errors.
In failureData (line 1215), populate errors on each transaction using ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericEditFailureMessage') (or a specific translation key for move failure). This ensures that if the move request fails, an error banner is displayed directly on the restored expense card.
Clean up newly created destination reports on move failure:
Accept an optional isNewReport?: boolean parameter in ChangeTransactionsReportProps (or inspect newReport?.pendingFields?.createReport === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD).
When useReportPickerActions.ts creates a report via createReportForPolicy and delegates to handleRegularReportSelection, pass isNewReport: true.
In changeTransactionsReport, when isNewReport is true, add rollback entries to failureData to remove the empty destination report:
This mirrors the existing optimistic cleanup pattern in Transaction.ts:1038–1055 and DeleteReport.ts, cleanly removing the $0 empty report from local state if the move cannot be completed.
What alternative solutions did you explore? (Optional)
We explored calling deleteAppReport unconditionally for any empty destination report on failure. However, an existing user report may legitimately have had 0 transactions prior to the move attempt; deleting it would destroy pre-existing user data. Restricting report removal specifically to isNewReport (reports instantiated during that move session) guarantees safe cleanup without side effects.
Please re-state the problem that we are trying to solve in this issue.
When moving an expense to another report (ChangeTransactionsReport) fails:
failureData silently moves the expense back to its original report without setting any error on the transaction, so the user sees no error banner or Red Brick Road (RBR) indicator explaining why the move was undone.
When the user chose "Create report" to move the expense into a newly created report, createNewReport (WRITE_COMMANDS.CREATE_APP_REPORT) succeeds on the server first, and when the subsequent ChangeTransactionsReport request fails, rolling back the transaction leaves an empty $0 report behind in Onyx (REPORT, REPORT_ACTIONS, parent REPORT_ACTIONS preview, and SNAPSHOT) and on the server.
Furthermore, getChangeTransactionsReportOnyxData never pushes searchUpdate.failureData (at src/libs/actions/Transaction.ts:1831-1836), so Search snapshot rows remain out of sync when a move fails.
What is the root cause of that problem?
failureData in getChangeTransactionsReportOnyxData (src/libs/actions/Transaction.ts:1212-1224) does not set errors or errorFields on the transaction, and omits searchUpdate.failureData:
At src/libs/actions/Transaction.ts#L1212-L1224, failureData restores reportID: transaction.reportID, comment: transaction.comment, etc., without setting errors: getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericEditFailureMessage') (unlike autoReportTransactions at lines 2287-2291 which explicitly sets errors on each transaction in failureData).
In addition, at src/libs/actions/Transaction.ts#L1831-L1836, searchUpdate.optimisticData and searchUpdate.successData are appended, but searchUpdate.failureData is never pushed to failureData.
createReportForPolicy creates the report via a separate CREATE_APP_REPORT write (src/libs/actions/Report/index.ts:5131), and ChangeTransactionsReport only rolls back total / transactionCount to 0 instead of removing the newly created report:
Then changeTransactionsReport is queued as a second request. When changeTransactionsReport fails (e.g. 456 because the expense creation was dropped, or a server/network error), Transaction.ts:1871-1917 and 2128-2135 merge {total: 0, transactionCount: 0, nextStep: ...} into ${ONYXKEYS.COLLECTION.REPORT}${reportID}. Even if a SET: null were pushed earlier in failureData, those later Onyx.METHOD.MERGE entries in steps 8 and 9 of getChangeTransactionsReportOnyxData would re-create a partial report object in Onyx unless reportID is excluded from steps 8 & 9 when removing the newly created report!
What changes do you think we should make in order to solve the problem?
Set errors on the transaction in failureData (and clear errors: null in optimisticData / successData) and include searchUpdate.failureData:
In src/libs/actions/Transaction.ts:
At lines 1188-1201 (optimisticData), include errors: null on ${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}.
At lines 1212-1224 (failureData), add errors: getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericEditFailureMessage'):
Remove the newly created empty report on move failure without re-merging it in steps 8 & 9:
Pass isNewReport?: boolean (or reportPreviewReportActionID?: string returned by createNewReport, which already returns {...optimisticReportData, reportPreviewReportActionID} at src/libs/actions/Report/index.ts:5150) from createReportForPolicy in useReportPickerActions.ts (and SearchTransactionsChangeReport.tsx) into handleRegularReportSelection$\rightarrow$changeTransactionsReport (ChangeTransactionsReportProps).
In getChangeTransactionsReportOnyxData (src/libs/actions/Transaction.ts):
When isNewReport && newReport?.reportID, in failureData:
Skip newReport.reportID in the failureData loops of Step 8 (updatedReportTotals, updatedReportUnheldTotals, updatedReportTransactionCounts, updatedReportNonReimbursableTotals, updatedReportStateNums, updatedReportReimbursableTotals) and Step 9 (affectedReportIDs) so later Onyx.METHOD.MERGE updates do not resurrect a partial report entry after SET: null.
Push cleanup updates to failureData to remove the empty report, its actions, its loading state, its parent chat REPORT_PREVIEW action, and its Search snapshot entry:
Add unit tests in tests/unit/TransactionTest.ts verifying that when changeTransactionsReport fails:
The transaction is restored to its original report with errors populated.
When moving to a newly created report (isNewReport: true), ${ONYXKEYS.COLLECTION.REPORT}${newReport.reportID} is completely removed (null in Onyx, not left behind as a partial or $0 report) and its parent REPORT_PREVIEW action is cleaned up.
What alternative solutions did you explore? (Optional)
Appending SET: null for ${ONYXKEYS.COLLECTION.REPORT}${reportID} at the start of getChangeTransactionsReportOnyxData without excluding reportID from steps 8 and 9: rejected because steps 8 and 9 (lines 1881-2135) push subsequent Onyx.METHOD.MERGE updates for reportID into failureData, which would execute after the SET: null and leave a broken partial report object {total: 0, transactionCount: 0, nextStep: ...} in Onyx.
When moving expenses to another report fails, the move is undone silently -
the expenses reappear in the old report with no error - and if the move
created a new destination report, that report is left behind, empty, with a
$0 total.
Root cause
Both defects are in the failure data of changeTransactionsReport
(src/libs/actions/Transaction.ts):
No error is set. The transaction failure entry (lines 1214-1225)
restores reportID, comment, originalAmount and originalCurrency,
but contains no errors field. The user sees the expense back where it
started and is told nothing.
A destination report created by this flow is never cleaned up. The
same function already knows how to do this: its selfDM branch appends
failure entries that remove the report it created - Onyx.METHOD.MERGE
with value: null for the REPORT, REPORT_METADATA and REPORT_ACTIONS
keys (lines 1038-1055). The newReport branch has no equivalent, so a
failed "move to new report" leaves the empty report behind.
The flow can tell whether it created the destination: callers pass newReport as either an existing report
(DynamicIOURequestEditReport.tsx) or a freshly created optimistic one
(SearchTransactionsChangeReport.tsx passes optimisticReport). A
just-created report carries the marker pendingFields.createReport
(set at creation, src/libs/ReportUtils.ts:8570); an existing report
does not.
The report totals/counts rollback already exists (lines 1870-1916) - only
the error surface and the created-report cleanup are missing.
Changes
Set an error on every moved transaction. Add errors to the
transaction failure entry, using the generic failure pattern this file
already uses for the same purpose (Transaction.ts:2290 sets errors: getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericEditFailureMessage')).
The expense returns to its original report WITH the failure shown, so the
user knows the move did not happen and can retry.
Delete a destination report this flow created. When newReport?.pendingFields?.createReport is set, append failure entries
mirroring the selfDM cleanup in the same function - Onyx.METHOD.MERGE
with value: null for:
METHOD.MERGE with null, not METHOD.SET: MERGE-with-null is the pattern
this codebase uses to remove a created report's keys (the selfDM branch
directly above), and it does not clobber sibling state the way a SET of
the whole key would. When newReport is a pre-existing report (no createReport pending field), nothing is deleted - the destination
report stays, exactly as today.
Not changed: the optimistic move, the success data, the totals/counts
rollback, the selfDM branch, and moves to pre-existing reports (other than
now showing the error).
Tests
In tests/unit/TransactionTest.ts and tests/actions/TransactionTest.ts
(both already cover changeTransactionsReport):
A failed move sets errors on each moved transaction and restores its
original reportID.
A failed move to a NEW report (created by the flow) removes the
destination report, its metadata and its report actions - no empty $0
report remains.
A failed move to a PRE-EXISTING report leaves that report in place
(regression control for the createReport marker check).
A successful move to a new report keeps the report and clears the pending
state as today.
Alternatives considered
METHOD.SET with null for the report cleanup (as in one existing
proposal). Rejected: it contradicts the cleanup pattern used in this very
function for the selfDM report; consistency here is not cosmetic, SET and
MERGE behave differently for keys other writers have touched.
A new isNewReport parameter threaded from the callers. Rejected as
unnecessary: pendingFields.createReport already records exactly this
fact on the report object the function receives, and threading a param
means touching all six call sites for information that is already there.
Delete empty $0 reports lazily on next app load. Rejected: the empty
report is visible in the meantime, and a lazy sweep races with a user
retrying the move into the same report.
@mountiny Apologies for that. I posted proposals on a few External issues before the Help Wanted label was added, and I understand now that proposals are only accepted once an issue carries that label. From here on I will only post proposals on Help Wanted labelled issues. Sorry for the noise.
Hi! I'm interested in working on this issue. I have a complete fix already coded and tested locally. Could I be assigned? I can submit the PR immediately once assigned. Stack: React Native + TypeScript. All communication is async/written — no calls needed.
Please re-state the problem that we are trying to solve in this issue.
When moving expenses to a destination report fails mid-way, an empty $0 report artifact is left behind in the reports list, polluting the UI with a ghost report the user cannot interact with meaningfully.
What is the root cause of that problem?
The "move expenses" action creates the destination report first, then moves expenses. If the move fails after the report creation, there is no cleanup step to delete the now-empty destination report.
What changes do you think we should make in order to solve the problem?
File — the report move/merge action (wherever moveExpensesToReport or equivalent is implemented):
Wrap the move operation in a try/catch.
On failure, check if the destination report now has 0 expenses (i.e. the move did not succeed for any expense).
If empty, call the report deletion API to purge the orphaned destination report.
Restore the original expenses to their source report if any were partially moved.
Surface a user-visible error message.
What specific scenarios should we test?
Move succeeds → destination report has expenses, source has none. No orphan.
Move fails before first expense moved → destination report deleted, source unchanged.
@Ollyws@mountiny@adhorodyski this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
Activity
expensify-chore-bot commentedon Nov 16, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (
External)[-]A failed move to another report is undone silently and leaves an empty $0 report[/-][+][$175] A failed move to another report is undone silently and leaves an empty $0 report[/+]expensify-chore-bot commentedon Nov 16, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022122192342223165070
MelvinBot commentedon Nov 16, 2026
Proposal
What is the root cause of that problem?
Medium confidence: Failed moves restore the expense without adding a fallback error. Separately, creating the destination and moving the expense are independent requests, so a failed move does not undo successful report creation.
Code evidence and limitations
Alternative checked: Server responses can supply their own errors through
onyxData; therefore, not every rejection is necessarily silent (OnyxUpdates.ts:74–111).These findings explain the reported symptoms when creation succeeds and the subsequent move fails without a server-supplied error. They do not establish why the move was rejected. Production logs were unavailable, the reported ~170 failures/day was not independently verified, and no browser reproduction was performed.
What changes do you think we should make in order to solve the problem?
Escalate the complete fix to an internal engineer for server-side lifecycle review. The required behavior is a visible failure on the restored expense plus safe, persistent cleanup of a destination created exclusively for that failed move.
An App-only removal from local state would hide, not delete, a persisted report. Existing report deletion can also unreport transactions, and its inspected request has no “only if still empty” guard (Report/index.ts:7548–7561, 7939–7946). Guaranteed cleanup therefore needs backend coordination, not an unverified App-only deletion.
Validation should cover successful creation followed by failed movement, existing destinations, concurrent additions, successful retry, and persistence after reload.
What alternative solutions did you explore? (Optional)
Deleting every empty destination is unsafe: it may predate the move or have acquired other content. A visible error alone addresses the silent rollback but leaves the empty-report symptom unresolved.
Related work
Next Steps for Contributor+ team:
Internal engineering review is required before accepting implementation.
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/106962)to create a draft PR once an App-scoped plan is confirmed.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
kevinjosh10 commentedon Nov 16, 2026
Proposal
What is the root cause of that problem?
There are two distinct root causes contributing to this behavior:
In
src/libs/actions/Transaction.ts(changeTransactionsReport, lines 1212–1225), when theChangeTransactionsReportAPI command fails,failureDatareverts the transaction'sreportID,comment, and currency/amount values back to their pre-move state:Unlike other money request mutations (e.g.
changeTransactionsToAutomaticReportinTransaction.ts:2290orUpdateMoneyRequest.ts),failureDatadoes not seterrorson the transaction object. Therefore, when the server rejects the move request, the expense is moved back to the original report with zero visual feedback or Red Brick Road (RBR) indicator.When moving an expense via the "Create report" option (
createReportForPolicyinsrc/pages/iou/request/step/IOURequestStepReport/hooks/useReportPickerActions.ts:220–239), an optimistic report is created viacreateNewReport(WRITE_COMMANDS.CREATE_APP_REPORT), followed immediately bychangeTransactionsReport(WRITE_COMMANDS.CHANGE_TRANSACTIONS_REPORT).In
Transaction.ts:1870–1916,failureDatareverts the destination report'stotal,unheldTotal, andtransactionCount. However, because the destination report itself was optimistically generated for this move, rolling back the totals leaves an empty, unlinked report with$0total in Onyx (ONYXKEYS.COLLECTION.REPORT) and the LHN/search views, instead of cleaning it up as done forselfDMReportinTransaction.ts:1038–1055.What changes do you think we should make in order to solve the problem?
In
src/libs/actions/Transaction.tsinsidechangeTransactionsReport:optimisticData, seterrors: nullon each moving transaction to clear any previous transient errors.failureData(line 1215), populateerrorson each transaction usingErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericEditFailureMessage')(or a specific translation key for move failure). This ensures that if the move request fails, an error banner is displayed directly on the restored expense card.isNewReport?: booleanparameter inChangeTransactionsReportProps(or inspectnewReport?.pendingFields?.createReport === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD).useReportPickerActions.tscreates a report viacreateReportForPolicyand delegates tohandleRegularReportSelection, passisNewReport: true.changeTransactionsReport, whenisNewReportis true, add rollback entries tofailureDatato remove the empty destination report:This mirrors the existing optimistic cleanup pattern in
Transaction.ts:1038–1055andDeleteReport.ts, cleanly removing the $0 empty report from local state if the move cannot be completed.What alternative solutions did you explore? (Optional)
deleteAppReportunconditionally for any empty destination report on failure. However, an existing user report may legitimately have had 0 transactions prior to the move attempt; deleting it would destroy pre-existing user data. Restricting report removal specifically toisNewReport(reports instantiated during that move session) guarantees safe cleanup without side effects.Contributor Details:
cocvn157 commentedon Nov 16, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When moving an expense to another report (
ChangeTransactionsReport) fails:failureDatasilently moves the expense back to its original report without setting any error on the transaction, so the user sees no error banner or Red Brick Road (RBR) indicator explaining why the move was undone.createNewReport(WRITE_COMMANDS.CREATE_APP_REPORT) succeeds on the server first, and when the subsequentChangeTransactionsReportrequest fails, rolling back the transaction leaves an empty$0report behind in Onyx (REPORT,REPORT_ACTIONS, parentREPORT_ACTIONSpreview, andSNAPSHOT) and on the server.getChangeTransactionsReportOnyxDatanever pushessearchUpdate.failureData(atsrc/libs/actions/Transaction.ts:1831-1836), so Search snapshot rows remain out of sync when a move fails.What is the root cause of that problem?
failureDataingetChangeTransactionsReportOnyxData(src/libs/actions/Transaction.ts:1212-1224) does not seterrorsorerrorFieldson the transaction, and omitssearchUpdate.failureData:src/libs/actions/Transaction.ts#L1212-L1224,failureDatarestoresreportID: transaction.reportID,comment: transaction.comment, etc., without settingerrors: getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericEditFailureMessage')(unlikeautoReportTransactionsatlines 2287-2291which explicitly setserrorson each transaction infailureData).src/libs/actions/Transaction.ts#L1831-L1836,searchUpdate.optimisticDataandsearchUpdate.successDataare appended, butsearchUpdate.failureDatais never pushed tofailureData.createReportForPolicycreates the report via a separateCREATE_APP_REPORTwrite (src/libs/actions/Report/index.ts:5131), andChangeTransactionsReportonly rolls backtotal/transactionCountto0instead of removing the newly created report:src/pages/iou/request/step/IOURequestStepReport/hooks/useReportPickerActions.ts#L226-L238(andSearchTransactionsChangeReport.tsx),createNewReport(...)writes:${ONYXKEYS.COLLECTION.REPORT}${reportID}${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}${ONYXKEYS.COLLECTION.RAM_ONLY_REPORT_LOADING_STATE}${reportID}${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}([reportPreviewReportActionID]: optimisticReportPreview)${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}changeTransactionsReportis queued as a second request. WhenchangeTransactionsReportfails (e.g.456because the expense creation was dropped, or a server/network error),Transaction.ts:1871-1917and2128-2135merge{total: 0, transactionCount: 0, nextStep: ...}into${ONYXKEYS.COLLECTION.REPORT}${reportID}. Even if aSET: nullwere pushed earlier infailureData, those laterOnyx.METHOD.MERGEentries in steps 8 and 9 ofgetChangeTransactionsReportOnyxDatawould re-create a partial report object in Onyx unlessreportIDis excluded from steps 8 & 9 when removing the newly created report!What changes do you think we should make in order to solve the problem?
Set
errorson the transaction infailureData(and clearerrors: nullinoptimisticData/successData) and includesearchUpdate.failureData:src/libs/actions/Transaction.ts:lines 1188-1201(optimisticData), includeerrors: nullon${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}.lines 1212-1224(failureData), adderrors: getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericEditFailureMessage'):lines 1831-1836, also pushsearchUpdate.failureData:Remove the newly created empty report on move failure without re-merging it in steps 8 & 9:
isNewReport?: boolean(orreportPreviewReportActionID?: stringreturned bycreateNewReport, which already returns{...optimisticReportData, reportPreviewReportActionID}atsrc/libs/actions/Report/index.ts:5150) fromcreateReportForPolicyinuseReportPickerActions.ts(andSearchTransactionsChangeReport.tsx) intohandleRegularReportSelectionchangeTransactionsReport(ChangeTransactionsReportProps).getChangeTransactionsReportOnyxData(src/libs/actions/Transaction.ts):isNewReport && newReport?.reportID, infailureData:newReport.reportIDin thefailureDataloops of Step 8 (updatedReportTotals,updatedReportUnheldTotals,updatedReportTransactionCounts,updatedReportNonReimbursableTotals,updatedReportStateNums,updatedReportReimbursableTotals) and Step 9 (affectedReportIDs) so laterOnyx.METHOD.MERGEupdates do not resurrect a partial report entry afterSET: null.failureDatato remove the empty report, its actions, its loading state, its parent chatREPORT_PREVIEWaction, and its Search snapshot entry:tests/unit/TransactionTest.tsverifying that whenchangeTransactionsReportfails:errorspopulated.isNewReport: true),${ONYXKEYS.COLLECTION.REPORT}${newReport.reportID}is completely removed (nullin Onyx, not left behind as a partial or$0report) and its parentREPORT_PREVIEWaction is cleaned up.What alternative solutions did you explore? (Optional)
SET: nullfor${ONYXKEYS.COLLECTION.REPORT}${reportID}at the start ofgetChangeTransactionsReportOnyxDatawithout excludingreportIDfrom steps 8 and 9: rejected because steps 8 and 9 (lines 1881-2135) push subsequentOnyx.METHOD.MERGEupdates forreportIDintofailureData, which would execute after theSET: nulland leave a broken partial report object{total: 0, transactionCount: 0, nextStep: ...}in Onyx.dankezo commentedon Nov 16, 2026
Contributor details
Your Expensify account email: dannyphan190@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab
Proposal
Problem
When moving expenses to another report fails, the move is undone silently -
the expenses reappear in the old report with no error - and if the move
created a new destination report, that report is left behind, empty, with a
$0 total.
Root cause
Both defects are in the failure data of
changeTransactionsReport(
src/libs/actions/Transaction.ts):No error is set. The transaction failure entry (lines 1214-1225)
restores
reportID,comment,originalAmountandoriginalCurrency,but contains no
errorsfield. The user sees the expense back where itstarted and is told nothing.
A destination report created by this flow is never cleaned up. The
same function already knows how to do this: its selfDM branch appends
failure entries that remove the report it created -
Onyx.METHOD.MERGEwith
value: nullfor the REPORT, REPORT_METADATA and REPORT_ACTIONSkeys (lines 1038-1055). The
newReportbranch has no equivalent, so afailed "move to new report" leaves the empty report behind.
The flow can tell whether it created the destination: callers pass
newReportas either an existing report(
DynamicIOURequestEditReport.tsx) or a freshly created optimistic one(
SearchTransactionsChangeReport.tsxpassesoptimisticReport). Ajust-created report carries the marker
pendingFields.createReport(set at creation,
src/libs/ReportUtils.ts:8570); an existing reportdoes not.
The report totals/counts rollback already exists (lines 1870-1916) - only
the error surface and the created-report cleanup are missing.
Changes
Set an error on every moved transaction. Add
errorsto thetransaction failure entry, using the generic failure pattern this file
already uses for the same purpose (
Transaction.ts:2290setserrors: getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericEditFailureMessage')).The expense returns to its original report WITH the failure shown, so the
user knows the move did not happen and can retry.
Delete a destination report this flow created. When
newReport?.pendingFields?.createReportis set, append failure entriesmirroring the selfDM cleanup in the same function -
Onyx.METHOD.MERGEwith
value: nullfor:${ONYXKEYS.COLLECTION.REPORT}${newReport.reportID}${ONYXKEYS.COLLECTION.REPORT_METADATA}${newReport.reportID}${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${newReport.reportID}METHOD.MERGE with null, not METHOD.SET: MERGE-with-null is the pattern
this codebase uses to remove a created report's keys (the selfDM branch
directly above), and it does not clobber sibling state the way a SET of
the whole key would. When
newReportis a pre-existing report (nocreateReportpending field), nothing is deleted - the destinationreport stays, exactly as today.
Not changed: the optimistic move, the success data, the totals/counts
rollback, the selfDM branch, and moves to pre-existing reports (other than
now showing the error).
Tests
In
tests/unit/TransactionTest.tsandtests/actions/TransactionTest.ts(both already cover
changeTransactionsReport):errorson each moved transaction and restores itsoriginal
reportID.destination report, its metadata and its report actions - no empty $0
report remains.
(regression control for the
createReportmarker check).state as today.
Alternatives considered
proposal). Rejected: it contradicts the cleanup pattern used in this very
function for the selfDM report; consistency here is not cosmetic, SET and
MERGE behave differently for keys other writers have touched.
isNewReportparameter threaded from the callers. Rejected asunnecessary:
pendingFields.createReportalready records exactly thisfact on the report object the function receives, and threading a param
means touching all six call sites for information that is already there.
report is visible in the meantime, and a lazy sweep races with a user
retrying the move into the same report.
melvin-bot commentedon Nov 16, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
15 remaining items
dankezo commentedon Nov 17, 2026
@mountiny Apologies for that. I posted proposals on a few External issues before the Help Wanted label was added, and I understand now that proposals are only accepted once an issue carries that label. From here on I will only post proposals on Help Wanted labelled issues. Sorry for the noise.
RajGahoi commentedon Nov 18, 2026
Hi! I'm interested in working on this issue. I have a complete fix already coded and tested locally. Could I be assigned? I can submit the PR immediately once assigned. Stack: React Native + TypeScript. All communication is async/written — no calls needed.
RajGahoi commentedon Nov 18, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When moving expenses to a destination report fails mid-way, an empty $0 report artifact is left behind in the reports list, polluting the UI with a ghost report the user cannot interact with meaningfully.
What is the root cause of that problem?
The "move expenses" action creates the destination report first, then moves expenses. If the move fails after the report creation, there is no cleanup step to delete the now-empty destination report.
What changes do you think we should make in order to solve the problem?
File — the report move/merge action (wherever
moveExpensesToReportor equivalent is implemented):What specific scenarios should we test?
mountiny commentedon Nov 19, 2026
This is not open to proposals, please only post proposals on
Help Wantedissues otherwise you will be removed from the repo for spammingexpensify-chore-bot commentedon Nov 19, 2026
@adhorodyski Whoops! This issue is 2 days overdue. Let's get this updated quick!
expensify-chore-bot commentedon Nov 23, 2026
@adhorodyski Still overdue 6 days?! Let's take care of this!
Ollyws commentedon Nov 25, 2026
I think as Melvin says this will require some backend work.
expensify-chore-bot commentedon Nov 25, 2026
@adhorodyski Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!
expensify-chore-bot commentedon Nov 27, 2026
@adhorodyski 10 days overdue. Is anyone even seeing these? Hello?
mountiny commentedon Nov 28, 2026
@adhorodyski Should we look for someone with backend access to tackle this one or did you have a specific plan for it?
elirangoshen commentedon Nov 30, 2026
Hi Im investigating this issue - I would if and what we can do in the client side.
I already have some findings , so you can assign me as well
expensify-chore-bot commentedon Nov 30, 2026
@Ollyws @mountiny @adhorodyski this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!