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] [Exploratory] Split - Report of Employee appears in Admin workspace chat after revert split #103833
When the admin saves the edited splits, App looks up the workspace chat using the current user's account ID (the admin) instead of the report owner's (the employee). It then builds an optimistic report preview of the employee's report inside the admin's own workspace chat.
The employee's report is already submitted. Because of that, removing the split does not take the "revert split" path. It takes the normal edit-splits path (UpdateSplitTransaction). See SplitTransactionUpdate.ts:175-188 and L395.
On that path, the remaining split already lives in a workspace report, so isConfirmedWorkspaceTransaction is true. That triggers an override at SplitTransactionUpdate.ts:930-942. It calls getPolicyExpenseChat(currentUserPersonalDetails.accountID, ...), which returns the admin's chat. That chat replaces the correct employee chat that was already resolved from expenseReport.chatReportID (L348-L374).
getMoneyRequestInformation finds no preview for the employee's report in the admin's chat, so it creates one (MoneyRequestBuilder.ts:1706-1725). Removing a split changes the remaining split's amount, so this optimistic data is pushed. successData then clears its pending state, so the preview stays.
The override was added for the self DM case, where the current user is always the owner. It came in with Add splits for unreported expenses. The API params contain no chat ID, so this is a frontend-only bug.
What changes do you think we should make in order to solve the problem?
Use the chat at existingTransactionReport.chatReportID.
If that chat is not in Onyx, fall back to getPolicyExpenseChat(existingTransactionReport.ownerAccountID, policyID).
If neither exists, skip the override so the existing expenseReport.chatReportID fallback applies.
Optionally, set payeeAccountID and payeeEmail (L807-L809) to the report owner instead of the current user.
Add a unit test in which an admin edits splits on another member's submitted report. It should assert that no reportActions update targets the admin's workspace chat.
What alternative solutions did you explore? (Optional)
Limit the override to the self DM context only (when chatReport is the self DM). This is narrower, but the owner-based lookup also fixes delegate and admin edits from any screen.
Notes and open questions
This also likely affects normal edits (two or more splits, amount changed) on another member's report. The code takes the same override path. I have not reproduced this.
If the original split transaction ever has its real reportID in the admin's Onyx (instead of -2), the revert path would hit the same override. The fix above covers both paths.
I did not reproduce this in the browser, because the repro needs two accounts (employee and admin). The stray preview should disappear after a cache clear if it is local-only.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/103833) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
changed the title [-][Exploratory] Split - Report of Employee appears in Admin workspace chat after revert split[/-][+][$175] [Exploratory] Split - Report of Employee appears in Admin workspace chat after revert split[/+]on Oct 19, 2026
Please re-state the problem that we are trying to solve in this issue.
When an employee splits an expense on a workspace, submits the report, and a workspace admin opens Split expense on one of the splits, deletes one split row (leaving one remaining split), and saves, an optimistic report preview of the employee's expense report is erroneously created inside the admin's own workspace expense chat instead of staying solely in the employee's workspace expense chat.
What is the root cause of that problem?
Why saving one remaining split on a submitted report takes the UPDATE_SPLIT_TRANSACTION path:
In src/libs/actions/IOU/SplitTransactionUpdate.ts:441-442, hasEditableSplitExpensesLeft checks whether the remaining split's report is in an editable (unsubmitted) state, so for a submitted report isReverseSplitOperation is false and updateSplitTransactions executes the UPDATE_SPLIT_TRANSACTION loop across splitExpenses.
The confirmed-workspace override in src/libs/actions/IOU/SplitTransactionUpdate.ts:971-983 looks up the workspace expense chat using the current user's accountID (the admin) instead of the report owner's accountID (the employee):
For the surviving split, existingTransactionReport is the employee's workspace expense report, so isConfirmedWorkspaceTransaction (line 787) is true.
Because getPolicyExpenseChat matches report.ownerAccountID === accountID, passing currentUserPersonalDetails.accountID resolves the admin's own policy expense chat rather than the employee's policy expense chat (existingTransactionReport.chatReportID).
Lines 974–983 then overwrite both requestMoneyInformation.participantParams.participant.reportID and requestMoneyInformation.parentChatReport with the admin's workspace chat while keeping moneyRequestReportIDForSplit = splitTransaction?.reportID (the employee's expense report at line 1002).
Additionally, at lines 849–850, payeeEmail and payeeAccountID are unconditionally set to currentUserPersonalDetails instead of the report owner when existingTransactionReport belongs to another member.
Why getMoneyRequestInformation creates a stray report preview in the admin's workspace chat:
Inside getMoneyRequestInformation (src/libs/actions/IOU/MoneyRequestBuilder.ts), it searches parentChatReport (the admin's workspace chat) for an existing REPORT_PREVIEW action for moneyRequestReportID (the employee's expense report). Finding none in the admin's chat, it calls buildOptimisticReportPreview(parentChatReport, iouReport, ...) and pushes a brand-new optimistic REPORT_PREVIEW action into reportActions_<adminWorkspaceChatReportID>.
Because deleting one split changes the surviving split's amount (hasChanges = true at line 1217), lines 1615–1618 push moneyRequestInformationOnyxData.optimisticData (and successData, which clears pendingAction) into Onyx, leaving the employee's report preview permanently visible inside the admin's workspace chat.
What changes do you think we should make in order to solve the problem?
In src/libs/actions/IOU/SplitTransactionUpdate.ts:971-983, resolve workspaceChatReport from the split's own existingTransactionReport (chatReportID first, then ownerAccountID), never from currentUserPersonalDetails.accountID:
Resolve the report owner's workspace chat at lines 971–983:
If existingTransactionReport.chatReportID exists in allReportsList or reportDrafts, use it directly.
Otherwise, if existingTransactionReport.ownerAccountID is defined, look up getPolicyExpenseChat(existingTransactionReport.ownerAccountID, existingTransactionReport.policyID, allReportsList).
If neither resolves in Onyx, do not override participant / parentChatReport with the current user's chat; let the already-resolved fallbackPolicyParentChatReport / fallbackPolicyParticipant (lines 397-421, which already use expenseReport.chatReportID and expenseReport.ownerAccountID) remain in effect.
Add a regression test in tests/actions/IOUTest/SplitTest.ts:
Set up an employee-owned submitted workspace expense report (ownerAccountID: employeeAccountID, chatReportID: employeeChatReportID) with two split child transactions, and a separate admin policy expense chat (ownerAccountID: adminAccountID).
Call updateSplitTransactions as the admin with one remaining split and verify that reportActions_<adminChatReportID> receives no REPORT_PREVIEW action while the update targets employeeChatReportID and expenseReport.reportID.
What alternative solutions did you explore? (Optional)
Falling back to existingTransactionReport?.ownerAccountID ?? currentUserPersonalDetails.accountID: Rejected because if ownerAccountID is temporarily absent on a partial report object while chatReportID is present, falling back to currentUserPersonalDetails.accountID would re-introduce the exact same bug.
Only running the override when opened from Self DM: Rejected because an admin or copilot delegate can also edit splits from Search or directly from the report thread; resolving workspaceChatReport via existingTransactionReport.chatReportID / existingTransactionReport.ownerAccountID works consistently across all entry points.
Activity
applause-bot commentedon Oct 13, 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/0b44aa7aa44c142b52c3d76cc894fac985fa094656f730c37edccb8772678bd4
MelvinBot commentedon Oct 19, 2026
Proposal
What is the root cause of that problem?
When the admin saves the edited splits, App looks up the workspace chat using the current user's account ID (the admin) instead of the report owner's (the employee). It then builds an optimistic report preview of the employee's report inside the admin's own workspace chat.
UpdateSplitTransaction). See SplitTransactionUpdate.ts:175-188 and L395.isConfirmedWorkspaceTransactionis true. That triggers an override at SplitTransactionUpdate.ts:930-942. It callsgetPolicyExpenseChat(currentUserPersonalDetails.accountID, ...), which returns the admin's chat. That chat replaces the correct employee chat that was already resolved fromexpenseReport.chatReportID(L348-L374).getMoneyRequestInformationfinds no preview for the employee's report in the admin's chat, so it creates one (MoneyRequestBuilder.ts:1706-1725). Removing a split changes the remaining split's amount, so this optimistic data is pushed.successDatathen clears its pending state, so the preview stays.The override was added for the self DM case, where the current user is always the owner. It came in with Add splits for unreported expenses. The API params contain no chat ID, so this is a frontend-only bug.
What changes do you think we should make in order to solve the problem?
In the override at SplitTransactionUpdate.ts:930-932, resolve the chat of the transaction's own report:
existingTransactionReport.chatReportID.getPolicyExpenseChat(existingTransactionReport.ownerAccountID, policyID).expenseReport.chatReportIDfallback applies.Optionally, set
payeeAccountIDandpayeeEmail(L807-L809) to the report owner instead of the current user.Add a unit test in which an admin edits splits on another member's submitted report. It should assert that no
reportActionsupdate targets the admin's workspace chat.What alternative solutions did you explore? (Optional)
Limit the override to the self DM context only (when
chatReportis the self DM). This is narrower, but the owner-based lookup also fixes delegate and admin edits from any screen.Notes and open questions
reportIDin the admin's Onyx (instead of-2), the revert path would hit the same override. The fix above covers both paths.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/103833)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
melvin-bot commentedon Oct 19, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @FitseTLT (
External)[-][Exploratory] Split - Report of Employee appears in Admin workspace chat after revert split[/-][+][$175] [Exploratory] Split - Report of Employee appears in Admin workspace chat after revert split[/+]melvin-bot commentedon Oct 19, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022112159428493644892
melvin-bot commentedon Oct 22, 2026
@FitseTLT Whoops! This issue is 2 days overdue. Let's get this updated quick!
11 remaining items
jeffrey-graham commentedon Nov 7, 2026
melvin-bot commentedon Nov 7, 2026
FitseTLT commentedon Nov 9, 2026
Reviewing this week
melvin-bot commentedon Nov 10, 2026
@FitseTLT this issue is now 4 weeks old, please consider:
Thanks!
melvin-bot commentedon Nov 12, 2026
@FitseTLT Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
FitseTLT commentedon Nov 13, 2026
Not overdue
cocvn157 commentedon Nov 14, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When an employee splits an expense on a workspace, submits the report, and a workspace admin opens Split expense on one of the splits, deletes one split row (leaving one remaining split), and saves, an optimistic report preview of the employee's expense report is erroneously created inside the admin's own workspace expense chat instead of staying solely in the employee's workspace expense chat.
What is the root cause of that problem?
UPDATE_SPLIT_TRANSACTIONpath:src/libs/actions/IOU/SplitTransactionUpdate.ts:441-442,hasEditableSplitExpensesLeftchecks whether the remaining split's report is in an editable (unsubmitted) state, so for a submitted reportisReverseSplitOperationisfalseandupdateSplitTransactionsexecutes theUPDATE_SPLIT_TRANSACTIONloop acrosssplitExpenses.src/libs/actions/IOU/SplitTransactionUpdate.ts:971-983looks up the workspace expense chat using the current user'saccountID(the admin) instead of the report owner'saccountID(the employee):existingTransactionReportis the employee's workspace expense report, soisConfirmedWorkspaceTransaction(line 787) istrue.getPolicyExpenseChatmatchesreport.ownerAccountID === accountID, passingcurrentUserPersonalDetails.accountIDresolves the admin's own policy expense chat rather than the employee's policy expense chat (existingTransactionReport.chatReportID).requestMoneyInformation.participantParams.participant.reportIDandrequestMoneyInformation.parentChatReportwith the admin's workspace chat while keepingmoneyRequestReportIDForSplit = splitTransaction?.reportID(the employee's expense report at line 1002).payeeEmailandpayeeAccountIDare unconditionally set tocurrentUserPersonalDetailsinstead of the report owner whenexistingTransactionReportbelongs to another member.getMoneyRequestInformationcreates a stray report preview in the admin's workspace chat:getMoneyRequestInformation(src/libs/actions/IOU/MoneyRequestBuilder.ts), it searchesparentChatReport(the admin's workspace chat) for an existingREPORT_PREVIEWaction formoneyRequestReportID(the employee's expense report). Finding none in the admin's chat, it callsbuildOptimisticReportPreview(parentChatReport, iouReport, ...)and pushes a brand-new optimisticREPORT_PREVIEWaction intoreportActions_<adminWorkspaceChatReportID>.hasChanges = trueat line 1217), lines 1615–1618 pushmoneyRequestInformationOnyxData.optimisticData(andsuccessData, which clearspendingAction) into Onyx, leaving the employee's report preview permanently visible inside the admin's workspace chat.What changes do you think we should make in order to solve the problem?
In
src/libs/actions/IOU/SplitTransactionUpdate.ts:971-983, resolveworkspaceChatReportfrom the split's ownexistingTransactionReport(chatReportIDfirst, thenownerAccountID), never fromcurrentUserPersonalDetails.accountID:Resolve the report owner's workspace chat at lines 971–983:
existingTransactionReport.chatReportIDexists inallReportsListorreportDrafts, use it directly.existingTransactionReport.ownerAccountIDis defined, look upgetPolicyExpenseChat(existingTransactionReport.ownerAccountID, existingTransactionReport.policyID, allReportsList).participant/parentChatReportwith the current user's chat; let the already-resolvedfallbackPolicyParentChatReport/fallbackPolicyParticipant(lines 397-421, which already useexpenseReport.chatReportIDandexpenseReport.ownerAccountID) remain in effect.Add a regression test in
tests/actions/IOUTest/SplitTest.ts:ownerAccountID: employeeAccountID, chatReportID: employeeChatReportID) with two split child transactions, and a separate admin policy expense chat (ownerAccountID: adminAccountID).updateSplitTransactionsas the admin with one remaining split and verify thatreportActions_<adminChatReportID>receives noREPORT_PREVIEWaction while the update targetsemployeeChatReportIDandexpenseReport.reportID.What alternative solutions did you explore? (Optional)
existingTransactionReport?.ownerAccountID ?? currentUserPersonalDetails.accountID: Rejected because ifownerAccountIDis temporarily absent on a partial report object whilechatReportIDis present, falling back tocurrentUserPersonalDetails.accountIDwould re-introduce the exact same bug.workspaceChatReportviaexistingTransactionReport.chatReportID/existingTransactionReport.ownerAccountIDworks consistently across all entry points.expensify-chore-bot commentedon Nov 18, 2026
@FitseTLT Eep! 4 days overdue now. Issues have feelings too...
FitseTLT commentedon Nov 18, 2026
not overdue