You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Expense - Edit split when confirming delete expense of a split per diem expense #103802
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Version Number: 9.5.7-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:https://test-management.browserstack.com/projects/2219752/folder/57599982/test-cases/110878718 Email or phone of affected tester (no customers):gatantm+6105@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: macOS Safari App Component: Money Requests
Action Performed:
Launch New expensify logged in with an account with Per diem settign enabled on WS
Navigate to a Report that has just one Per diem expense (Or create one and move to a new report)
Open the report select More > Split > Confirm
Move the new expense to a new report
Go back to the WS chat with the two reports
Submit and Approve the first report
Right click and select delete on the second report from the chat and confirm
Expected Result:
The expense is deleted or the option is not available on the context menu
Actual Result:
The edit split page is shown when confirming the delete
Please re-state the problem that we are trying to solve in this issue.
A per diem expense is split into two expenses. One split sits in an approved report. When you delete the other split from the workspace chat context menu, the app opens the Edit split page instead of deleting it.
What is the root cause of that problem?
When you confirm Delete, deleteTransactions first checks whether it should send you to Edit split instead of deleting. That check, getSplitExpenseEditTransactionOnDelete, redirects any per diem split child on a report when the original expense has more than one split. It never checks whether the other splits can still be edited. In this case the only other split is in an approved report, so it can't be edited, but the redirect happens anyway.
The same function already has the right check, hasEditableSplitExpensesLeft. It turns the delete into a normal delete when no other split is editable. But it runs after the redirect returns early, so it never runs.
Path: context menu Delete → showDeleteModal → PopoverReportActionContextMenu confirm → deleteTransactions → getSplitExpenseEditTransactionOnDelete returns the transaction → initSplitExpense(..., {navigateToEditSplitExpense: true}).
What changes do you think we should make in order to solve the problem?
In getSplitExpenseEditTransactionOnDelete, only redirect if at least one other split is still editable. Use the same rule as hasEditableSplitExpensesLeft: the split's report is below SUBMITTED. Move that rule into a shared helper and use it in both places. With no editable splits left, the delete falls through to the normal deleteMoneyRequest path.
Other menus build "Edit splits" from shouldOpenSplitExpenseEditFlowOnDelete, which uses the same function. They will show "Delete" again in this case without extra work.
Add a unit test: per diem split with one split in an approved report; deleting the other split deletes it and does not redirect.
What alternative solutions did you explore? (Optional)
Make the context menu match the other menus. When the redirect applies, label the item "Edit splits" and skip the delete confirmation. Today only selfDM hides it. This fixes the confusing label but not the wrong redirect, so it should come in addition to step 1, not instead of it.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/103802) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
changed the title [-]Expense - Edit split when confirming delete expense of a split per diem expense[/-][+][$175] Expense - Edit split when confirming delete expense of a split per diem expense[/+]on Oct 12, 2026
Title:[$175] Expense - Edit split when confirming delete expense of a split per diem expense GitHub Issue:#103802 Assigned C+:@situchan Contributor: Janitha Dilshan (@janiya2) Upwork Profile:https://www.upwork.com/freelancers/janithad
1. Problem Restatement
When a per-diem expense is split into multiple expenses and one split is placed in a submitted/approved report, attempting to delete the other split from the chat context menu displays a "Delete expense" confirmation dialog. However, upon confirming deletion, instead of deleting the expense (or hiding the Delete option if not allowed), the application navigates to the Edit Split Expense page where the user cannot even remove the split because the other split is frozen/approved.
2. Root Cause Analysis
There are two interrelated root causes across the data and UI layers:
Premature redirection in getSplitExpenseEditTransactionOnDelete (useDeleteTransactions.ts:118-137):
When a user confirms deletion of a split expense, deleteTransactions checks getSplitExpenseEditTransactionOnDelete(transactionIDs) at line 166.
Currently, getSplitExpenseEditTransactionOnDelete only checks shouldRedirectDeleteToSplitExpenseEdit and hasMultipleSplits > 1. It does not check whether the other split expenses are still editable.
If the other split child resides in an approved/submitted report ((report.statusNum ?? 0) >= CONST.REPORT.STATUS_NUM.SUBMITTED), it is frozen and cannot absorb redistributed amounts.
Interestingly, line 263 of useDeleteTransactions.tsalready has the check hasEditableSplitExpensesLeft:
This fallback was specifically engineered to delete the expense via the standard deleteMoneyRequest path when no other splits can be edited. However, line 166 intercepts execution and returns early with { action: 'redirected' } before lines 240–270 are ever reached!
Consequently, the user is redirected to DynamicSplitExpenseEditPage, where canRemoveSplit is false (otherSplitExpenses.some((item) => !frozenSplitTransactionIDs.has(item.transactionID)) evaluates to false), trapping the user on an edit page where deletion is impossible.
Incomplete check in ContextMenuActions.tsx:1768-1774:
In ContextMenuActions.tsx, Delete is conditionally hidden with the following comment:
// Hide Delete for per-diem expense split children in selfDM — users must edit the// splits instead (matches the secondary "More" menu behavior).constchatReport=getReportOrDraftReport(reportIDParam);if(isSelfDM(chatReport)&&iouTransaction){constoriginalTransaction=transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${iouTransaction.comment?.originalTransactionID}`];if(isExpenseSplit(iouTransaction,originalTransaction)&&isPerDiemRequest(originalTransaction??iouTransaction)){returnfalse;}}
Restricting this guard to isSelfDM(chatReport) causes the context menu in workspace chats (and 1:1 / group chats) to show "Delete" even for active split per-diem expenses where confirming delete redirects to the Edit Split flow. Furthermore, it did not account for whether other splits are actually editable.
3. Proposed Solution
A. Extract Shared Helper hasEditableSplitExpenses in TransactionUtils/index.ts
Create a centralized helper to check if remaining child splits can be edited:
And replace the inline check at line 263 with hasEditableSplitExpenses(childTransactions, allReports).
C. Update Context Menu Logic in ContextMenuActions.tsx
Remove the arbitrary isSelfDM restriction and only hide Delete when the other splits are editable (i.e. when editing splits is the required flow):
--- a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx+++ b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx@@ -213,7 +213,7 @@ import {getTaskCreatedMessage, getTaskReportActionMessage} from '@libs/TaskUtils
-import {isExpenseSplit, isPerDiemRequest} from '@libs/TransactionUtils';+import {getChildTransactions, hasEditableSplitExpenses, isExpenseSplit, isPerDiemRequest} from '@libs/TransactionUtils';@@ -1766,12 +1766,13 @@ const ContextMenuActions: ContextMenuAction[] = [
- // Hide Delete for per-diem expense split children in selfDM — users must edit the- // splits instead (matches the secondary "More" menu behavior).- const chatReport = getReportOrDraftReport(reportIDParam);- if (isSelfDM(chatReport) && iouTransaction) {+ // Hide Delete for per-diem expense split children when remaining splits are editable — users must edit the+ // splits instead (matches the secondary "More" menu behavior).+ if (iouTransaction) {
const originalTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${iouTransaction.comment?.originalTransactionID}`];
if (isExpenseSplit(iouTransaction, originalTransaction) && isPerDiemRequest(originalTransaction ?? iouTransaction)) {
- return false;+ const childTransactions = getChildTransactions(transactions, originalTransaction?.transactionID);+ if (hasEditableSplitExpenses(childTransactions, allReports, iouTransaction.transactionID)) {+ return false;+ }
}
}
4. Alternative Solutions Considered
Transform Context Menu item into "Edit splits" instead of "Delete":
In chat context menus, items are uniform actions (Delete, Reply, Copy). Context menus do not support split manipulation wizards.
More importantly, when the other report is already approved, the split cannot be removed on the Edit Split page anyway. Therefore, transforming the label does not solve the root issue.
Only updating useDeleteTransactions.ts without fixing ContextMenuActions.tsx:
While this allows the delete to succeed when other splits are approved, it leaves open the confusing UX where draft per-diem splits show a "Delete" confirmation that unexpectedly opens the Edit Split page. Synchronizing both layers provides a cohesive experience.
Navigate to the Workspace chat containing previews for both reports.
Submit and Approve Report A.
Right-click Report B (or the expense action) from the chat and select Delete.
Confirm deletion in the modal.
Verify: The expense on Report B is successfully deleted and the user is NOT redirected to the Edit Split page.
Scenario 2: Both split reports are open/draft
Follow steps 1–5 above without submitting/approving either report.
Right-click either report from the Workspace chat.
Verify: The "Delete" option is not available in the context menu (users must use "Edit splits" from the report More menu).
Scenario 3: Report More Menu behavior
With Report A approved, open Report B directly.
Open the More menu (...).
Verify: The action displays "Delete" (with Trashcan icon) instead of "Edit splits". Clicking Delete prompts confirmation and deletes the expense cleanly.
Automated Unit Test:
Add a unit test in tests/unit/useDeleteTransactionsTest.ts:
it('should delete split per-diem expense directly when other splits are in submitted/approved reports',()=>{// 1. Mock original per-diem transaction with 2 child splits// 2. Set child 1 report status to SUBMITTED// 3. Set child 2 report status to OPEN// 4. Call deleteTransactions([child2.transactionID])// 5. Verify result action is 'deleted' (not 'redirected')});
getSplitExpenseEditTransactionOnDelete in useDeleteTransactions decides whether Delete should redirect to Edit split. It only checks that the transaction is a per diem split child (via shouldRedirectDeleteToSplitExpenseEdit) and that the original has more than one split. It never checks whether any other split can still be edited, so a sibling in an approved report still counts.
The Edit split flow can only work if there is another split the user can edit. The existing helper hasEditableSplitExpenseLeft (status below SUBMITTED) encodes that rule, but the delete path does not use it.
What changes do you think we should make in order to solve the problem?
In getSplitExpenseEditTransactionOnDelete, get the child transactions with getChildTransactions (already called) and exclude the one being deleted.
Redirect only if at least one remaining sibling's report has statusNum below SUBMITTED. Reuse the rule from hasEditableSplitExpenseLeft: map the siblings to {transactionID, reportID} and pass them with allTransactions and allReports. Or export a small shared helper.
If none are editable, return undefined so deleteTransactions runs the normal delete.
Apply the same check where the context-menu delete visibility is decided (shouldRedirectDeleteToSplitExpenseEdit caller in ReportSecondaryActionUtils), so both paths agree.
Add a unit test to useDeleteTransactions tests: a per diem split child whose only sibling is in an approved report must return deleted rather than redirected. Add a second case where the sibling's report is open and the result stays redirected.
What alternative solutions did you explore? (Optional)
Hide Delete when the only sibling is approved: this leaves the user with no way to remove the expense, so it is worse than letting the delete go through.
Put the check inside shouldRedirectDeleteToSplitExpenseEdit: that function only takes the transaction pair and has no access to the reports, so it would need a signature change for every caller.
Please re-state the problem that we are trying to solve in this issue.
When a user confirms the deletion of a split per-diem expense whose sibling split is in a submitted or approved report, the app redirects to the "Edit split" page instead of deleting the expense.
If the original transaction has more than one child split, it immediately returns the parent transaction to trigger redirection to the Edit Split flow (navigateToEditSplitExpense).
However, it fails to check whether any of the remaining sibling splits can actually be edited. If the sibling split is already in a submitted or approved report (statusNum >= CONST.REPORT.STATUS_NUM.SUBMITTED), the Edit Split page cannot modify or remove the split, leaving the user unable to delete their expense.
What changes do you think we should make in order to solve the problem?
In src/hooks/useDeleteTransactions.ts, inside getSplitExpenseEditTransactionOnDelete, filter the sibling transactions to exclude the transaction being deleted:
Verify if any remaining sibling is editable using the existing logic from hasEditableSplitExpenseLeft (checking if statusNum < CONST.REPORT.STATUS_NUM.SUBMITTED).
If no other editable split exists, return undefined, allowing deleteTransactions to proceed with the normal deletion flow and removing the expense cleanly.
Align ReportSecondaryActionUtils / ContextMenuActions so the delete action visibility matches the executable deletion state.
Add unit tests in tests/unit/useDeleteTransactionsTest.ts to assert that deleting a split per-diem expense whose only sibling is in an approved report results in a direct deletion (deleted) rather than a redirect (redirected).
What alternative solutions did you explore? (Optional)
Disabling the Delete option entirely when a sibling split is approved: rejected because it prevents users from deleting legitimate orphan expenses on open reports.
Root cause: After a per diem expense is split, deleting the second split from the workspace chat context menu navigates to the Edit split bill RHP instead of deleting. The confirm-delete path on a split child resolves to the split-edit screen because the expense is recognized as a split, so the deletion never completes and the edit page opens instead.
Fix approach:
Make the confirm-delete path on a split expense call the delete money request action and dismiss the confirmation, bypassing the Edit split RHP entirely.
Guard the Edit split page navigation so it only opens from genuine edit actions, not from the delete confirmation flow.
Verification: Follow the exact repro (split a per diem expense, move the new expense to a new report, submit and approve the first report, then delete the second report from the chat and confirm) and confirm the expense is deleted and the report is removed. Also confirm the delete flow on a non-split expense is unchanged and that the Edit split page still opens correctly from a real edit action.
Please re-state the problem that we are trying to solve in this issue.
Split a per diem expense across two reports and approve the first report. In the workspace chat, right-click the second report preview, choose Delete, and confirm. Instead of either hiding Delete or deleting safely, the app opens the Edit split page (DynamicSplitExpenseEditPage), where Remove split is hidden because the approved sibling split cannot absorb the removed amount.
What is the root cause of that problem?
Two places make inconsistent decisions about whether a per diem split child can be deleted or edited:
Workspace chat context menu leaves Delete visible even when deletion redirects or cannot succeed: In ContextMenuActions.tsx, right-clicking a single-expense report preview resolves actionToDelete to the author's moneyRequestAction (L1898), then only hides Delete for per diem split children when isSelfDM(chatReport) is true (L1911-L1917). In workspace chat (policyExpenseChat), Delete stays visible even when every other split is frozen (isSplitExpenseFrozen in SplitExpenseUtils.ts), so per diem's exact-sum constraint makes it impossible to redistribute the amount (canRemoveSplit is false in DynamicSplitExpenseEditPage.tsx).
useDeleteTransactions redirects unconditionally without checking sibling report editability: In useDeleteTransactions.ts, getSplitExpenseEditTransactionOnDelete only checks shouldRedirectDeleteToSplitExpenseEdit and hasMultipleSplits (childTransactions.length > 1), then deleteTransactions immediately opens DynamicSplitExpenseEditPage and returns {action: 'redirected'} without checking whether any surviving sibling split belongs to a report that can still absorb the amount (not frozen by isSplitExpenseFrozen / isSplitAction). Meanwhile, useDeleteReportAction.ts only short-circuits on deleteResult.action === 'redirected'.
Reproduction Steps (1 tab):
Open a workspace with Per diem enabled and create a Per diem expense.
Open the expense, select More > Split > Confirm, and move the second split to a new report.
Submit and approve the first report.
Return to the workspace chat, right-click the second (draft) report preview, choose Delete, and confirm: Edit split opens with no way to remove the split.
What changes do you think we should make in order to solve the problem?
Align the menu visibility and delete execution around a single shared decision function (delete, editSplits, or blocked):
Add a shared helper (e.g. getPerDiemSplitDeleteDecision in src/libs/TransactionUtils/index.ts alongside shouldRedirectDeleteToSplitExpenseEdit):
Keep existing per diem eligibility and childTransactions.length > 1 checks so ordinary expenses and the last remaining active split still evaluate to {action: 'delete'}. When multiple active splits exist, check whether any surviving sibling (child.transactionID !== transaction.transactionID) can absorb the removed amount (unreported or on an unfrozen report where !isSplitExpenseFrozen(siblingReport)):
Hide Delete in ContextMenuActions.tsx when the resolved action targets an un-deletable per diem split child:
When isMoneyRequestAction(actionToDelete) and iouTransaction is an active per diem split child (isExpenseSplit(iouTransaction, originalTransaction) && isPerDiemRequest(originalTransaction ?? iouTransaction)), check the child splits across transactions: if getPerDiemSplitDeleteDecision returns 'blocked' (or when isSelfDM(chatReport)), return false so Delete is not offered on a split whose sibling is frozen/approved. Keep Delete visible when only 1 active split remains ('delete') or when an admin is deleting the report preview itself (actionToDelete === reportAction). Also allow the workspace chat context menu to show Delete -> Edit splits only when an unfrozen sibling exists, or hide it cleanly when blocked.
Handle 'blocked' safely in useDeleteTransactions.ts and useDeleteReportAction.ts:
Re-evaluate getPerDiemSplitDeleteDecision inside deleteTransactions. If the sibling report was approved while the confirmation modal was open, return {action: 'blocked'} before opening DynamicSplitExpenseEditPage or mutating the expense, and close the modal in useDeleteReportAction without emitting deletedReportAction_*:
Confirm that in a 2-split per diem expense where split 1 is approved, right-clicking split 2 in workspace chat hides Delete (and if the confirmation modal was opened before split 1 was approved, confirming closes the modal without opening Edit splits or violating the per diem total).
Confirm that when split 1 is still draft/editable, Edit splits still opens and allows redistributing amounts.
Confirm that deleting the last remaining active split (when childTransactions.length === 1) and deleting non-per-diem splits continue to delete normally.
What alternative solutions did you explore? (Optional)
Deleting the draft per diem split directly when all siblings are approved would leave the remaining frozen split's total lower than the original per diem expense amount, breaking the requiresExactSum invariant enforced in SplitExpenseUtils.ts and DynamicSplitExpenseEditPage.tsx. Blocking deletion and hiding Delete via a shared decision helper preserves the exact-sum invariant and matches the expected behavior of not offering an impossible delete.
🚨 Edited by proposal-police: This proposal was edited at 2026-12-04 16:33:59 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a per diem expense is split across two reports and the first report is submitted and approved, right-clicking the second (draft) report preview in the workspace chat, choosing Delete, and confirming opens the Edit split page (DynamicSplitExpenseEditPage) instead of deleting the expense—where Remove split is hidden because the approved sibling split is frozen, leaving the user stuck.
Reproduction steps:
Enable Per diem on a workspace and create a per diem expense on a report.
Open the report, select More > Split > Confirm, and move the second split expense to a new report.
In the workspace chat showing both report previews, submit and approve the first report.
Right-click the second report preview in the workspace chat, select Delete, and confirm: Edit split opens with no Remove split button instead of deleting the draft expense.
What is the root cause of that problem?
The chat context menu, the delete hook, and the split editor enforce different rules for when a per diem split child can be deleted versus edited:
Workspace chat exposes a misleading Delete confirmation for active per diem splits, while selfDM over-hides Delete: On a single-expense report preview, ContextMenuActions.tsx resolves actionToDelete to the author's moneyRequestAction, but only checks isSelfDM(chatReport) when hiding Delete for per diem split children (and BaseReportActionContextMenu.tsx only loads childReport's transactions, omitting originalTransaction and sibling splits on other reports). As a result, workspace chats show Delete + a "Delete expense" confirmation modal even when confirming redirects into Edit split, whereas selfDM hides Delete even when only one split remains or all siblings are frozen.
getSplitExpenseEditTransactionOnDelete redirects without checking whether DynamicSplitExpenseEditPage can remove the split: In useDeleteTransactions.ts, getSplitExpenseEditTransactionOnDelete returns the transaction whenever hasMultipleSplits (> 1), causing deleteTransactions to open DynamicSplitExpenseEditPage early. On DynamicSplitExpenseEditPage.tsx, per diem requires an exact sum (requiresExactSum), so canRemoveSplit is false whenever every sibling split is in frozenSplitTransactionIDs—i.e., its report is approved/settled/closed (isSplitExpenseFrozen) or !isSplitAction(...) (useFrozenSplitTransactionIDs.ts). Additionally, useFrozenSplitTransactionIDs lets itemTransaction?.reportID ('0' for unreported splits) shadow item.reportID and fall back to another split's fallbackReport, and passes the caller's parentReport instead of each sibling's own parent report.
What changes do you think we should make in order to solve the problem?
Unify the context menu, delete pipeline, and secondary menus around the split editor's own frozen-split and removability predicates:
Extract getFrozenSplitTransactionIDs and canRemoveSplitExpense into src/libs/SplitExpenseUtils.ts:
Move the pure loop out of useFrozenSplitTransactionIDs.ts into getFrozenSplitTransactionIDs (typing splitExpenses as Array<Pick<SplitExpense, 'transactionID' | 'reportID'>>, resolving CONST.REPORT.UNREPORTED_REPORT_ID via item.reportID / selfDMReportID before fallbackReport, and resolving each split's own itemReport?.parentReportID before parentReport), and add canRemoveSplitExpense:
In getSplitExpenseEditTransactionOnDelete, filter otherChildTransactions (excluding transaction.transactionID), compute frozenSplitTransactionIDs (passing selfDMReportID and currentSearchResults?.data), and return undefined when otherChildTransactions.length === 0 or !canRemoveSplitExpense(originalTransaction ?? transaction, otherChildTransactions, frozenSplitTransactionIDs). When every sibling is frozen (such as in an approved report), deleteTransactions skips the redirect and deletes the draft split cleanly via deleteMoneyRequest.
In deleteTransactions, compute frozenSplitTransactionIDs for childTransactions, scope the !frozenSplitTransactionIDs.has(child.transactionID) check in hasEditableSplitExpensesLeft (L268-L271) to exact-sum splits (isPerDiemRequest / isManagedCardTransaction, keeping statusNum < SUBMITTED for 1:1 IOU and regular cash splits where isSplitAction is false or rebalancing does not apply), and export redistributeExcludingFrozenSplits from SplitExpenseItems.ts to replace redistributeRemainingPerDiemSplitExpenses (L70-L82, L290) so multi-select per diem deletions preserve frozen siblings while rebalancing unfrozen ones.
Align chat context menu Delete visibility across all chats in ContextMenuActions.tsx and BaseReportActionContextMenu.tsx:
Add a selector-based hook useShouldRedirectPerDiemSplitDelete (following useHasMultipleSplitChildren's O(1) early exit whenever isMini, !isVisible, or iouTransaction is not a per diem split child, so hover menus and closed popovers do zero collection work). In common.delete's shouldShow, replace the isSelfDM(chatReport)-only check so Delete is hidden whenever isMoneyRequestAction(actionToDelete) and shouldRedirectPerDiemSplitDelete is true (an unfrozen sibling must absorb the amount in Edit splits), and Delete is shown whenever all sibling splits are frozen or only one split remains (including in selfDM), while preserving admin REPORTPREVIEW deletion.
Preserve Split (Edit splits) in secondary More menus when Delete performs a real delete:
Add an optional shouldOpenSplitEditOnDelete?: boolean parameter to shouldShowEditSplitInDeleteAction (keeping && isDeleteAction(...) intact so forwarded reports where Delete is hidden still offer Split), getSecondaryReportActions, and getSecondaryTransactionThreadActions in ReportSecondaryActionUtils.ts, and pass the computed shouldShowEditSplitOnDeleteAction from MoneyRequestHeaderSecondaryActions.tsx and useExpenseActions.ts / MoneyReportHeaderSecondaryActions.tsx. Add unit tests covering approved, submitted-awaiting-approval, forwarded/un-splittable, self-DM, 1:1 IOU, 3-way frozen+editable redistribution, and chat context-menu scenarios.
What alternative solutions did you explore? (Optional)
Gate redirection on statusNum < CONST.REPORT.STATUS_NUM.SUBMITTED (Draft PR #106019): Rejected because splits on a submitted report awaiting approval (or viewed by an admin/manager) are still editable via isSplitAction and not frozen, so plain-deleting them skips rebalancing and corrupts the split total upon retraction; conversely, splits on an open report the user cannot split would still redirect into a dead end.
Hide or block Delete even when all sibling splits are frozen: Rejected because once a sibling report is approved or reimbursed, a submitter cannot reopen it and would be permanently stranded with an undeletable draft expense on the second report.
How this proposal differs from earlier proposals on this issue:
Unifies chat context menus with the delete hook and More menu: Hook-only proposals leave ContextMenuActions.tsx showing a misleading "Delete expense" confirmation dialog on workspace-chat right-click when confirming opens Edit split (while over-hiding Delete in selfDM when sole-split or all siblings are frozen); conversely, context-menu-only proposals leave More, ReportDetails, bulk selection, or approved-sibling draft deletion broken.
Prevents overwriting frozen siblings during multi-split deletions without regressing 1:1 IOU/cash splits: Earlier hook proposals keep redistributeRemainingPerDiemSplitExpenses, which evenly overwrites frozen/approved sibling amounts in 3+ way per diem splits; replacing it with redistributeExcludingFrozenSplits and scoping the !frozenSplitTransactionIDs check in hasEditableSplitExpensesLeft to exact-sum splits protects both approved per diem siblings and 1:1 IOU / submitted cash splits.
Note: Before submitting a proposal on an issue, be sure to read any other existing proposals. ALL NEW PROPOSALS MUST BE DIFFERENT FROM EXISTING PROPOSALS. The difference should be important, meaningful or considerable.
There are already 20+ proposals, and many of them seem quite similar. I would kindly request everyone to revisit their proposals and make sure they are meaningfully different from the proposals posted before.
@sobitneupane I compared my proposal with the ones posted before it. All but one change the delete flow in useDeleteTransactions (getSplitExpenseEditTransactionOnDelete) so the split is deleted directly when the other splits are frozen, some with a context-menu change on top. Mine leaves deleteTransactions and its redirect to Edit splits as they are, because removing a per diem split anywhere else breaks the exact sum, and changes only the chat context menu: the self-DM-only check becomes the same "more than one split" count deleteTransactions uses, so Delete is hidden in every chat exactly when confirming it would open Edit splits, which is when the More menu already shows "Edit splits" instead of Delete. The only other context-menu-only proposal adds a workspace-chat check that hides Delete only when every other split is frozen, and keeps Delete with the redirect in every other case.
I would kindly request everyone to revisit their proposals and make sure they are meaningfully different from the proposals posted before.
My proposal was posted at the same time as the four proposals above it. Compared with them:
With all four, when the only other split is approved, the open split's More menu shows Delete without Split or Edit splits, so it can't be split again. Mine keeps Edit splits there (see the "Additionally" section)
Three of them use a different frozen check from the edit split page, so they still dead-end or regress in some cases. The fourth uses the same check as mine, but mine also handles splits in self DM
Before Help Wanted, I also reported the regressions in Melvin's draft when the other splits are in a submitted report, and my proposal avoids them
If the product/design team would rather hide Delete than delete the split, my alternative covers that too, backed by the backend error for per diem split updates that don't add up and a comment from the product team here
Details
This proposal and this one only check isSplitExpenseFrozen (approved, paid or closed). A report forwarded to a second approver isn't approved yet, but a submitter who isn't an admin can't split it anymore, so the edit split page has no Remove split there and their fix still redirects to it. With mine, Delete works there (tested with two-level approval)
This proposal treats every split in a submitted report as not editable (statusNum < SUBMITTED), the same rule as Melvin's draft, so it has the same regressions
This proposal moves the frozen check out of useFrozenSplitTransactionIDs like mine. Mine also checks splits in self DM (report ID 0) against the self DM report (fallbackReport). Without that, my first version showed Delete instead of Edit splits in the report header when the other split was in self DM
My alternative includes the backend response for per diem split updates that don't add up ("The sum of split amounts must exactly match the original amount") and this comment: "You shouldn't be able to delete a single per diem split outside of the 'edit splits' table"
Note: Before submitting a proposal on an issue, be sure to read any other existing proposals. ALL NEW PROPOSALS MUST BE DIFFERENT FROM EXISTING PROPOSALS. The difference should be important, meaningful or considerable.
There are already 20+ proposals, and many of them seem quite similar. I would kindly request everyone to revisit their proposals and make sure they are meaningfully different from the proposals posted before.
@sobitneupane I updated my original proposal with paired local test results. The main difference from Yusuf’s approach is that mine keeps Remove split reachable from workspace chat when the submitted sibling is still editable. Once the sibling is approved, the patch hides Delete and preserves both split amounts.
@sobitneupane Thanks for review!, Sharing why my unedited proposal (2026-11-30T10:56:41Z, before the later edits and Dec 1–3 updates) is meaningfully different and avoids bugs in the earlier ones:
1. Why my proposal is meaningfully different
Earlier statusNum / isSplitExpenseFrozen-only / context-menu-hide proposals either break submitted-awaiting-approval or uneditable open splits, hide Split in the More menu when Delete stops redirecting, or leave the second report undeletable.
Vs. #issuecomment-7275630627 (zeryns):
Fixes silent rebalancing onto uneditable/Search-only siblings:zeryns leaves hasEditableSplitExpensesLeft checking only allReports and statusNum < SUBMITTED, so an uneditable open sibling or Search-only approved sibling skips Edit Splits and gets rebalanced anyway. Mine aligns that fallback for per diem splits and reads Search data.
Fixes wrong fallbackReport:zeryns passes searchResultsData: undefined and fallbackReport: selfDMReport ?? report, which marks an unloaded approved sibling as editable. Mine maps '0' to selfDMReportID, resolves each sibling's own parent report, and never falls back to another split's report.
Vs. #issuecomment-7275758291 (dostonbunyodov0006, plus oqildev / David-2002065):
Avoids 1:1 IOU and submitted cash-split regressions: Replacing hasEditableSplitExpensesLeft with !frozen for all splits breaks 1:1 IOU cash splits (since isSplitAction returns false on non-expense reports) and silently edits submitted cash reports on bulk delete. Mine keeps statusNum < SUBMITTED and applies the frozen check only to per diem splits.
Avoids forwarded-report menu regression & touches fewer files: Replacing shouldShowEditSplitInDeleteAction drops isDeleteAction, hiding Split on forwarded reports where Delete is hidden. Mine keeps isDeleteAction intact and leaves DynamicSplitExpenseEditPage.tsx untouched.
2. Where this exact approach already exists in the app
Same frozen + isSplitAction + Search snapshot check already used by Edit Splits (and tested in useFrozenSplitTransactionIDs.test.ts):
⚠️@yaswar Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).
In src/hooks/useDeleteTransactions.ts, getSplitExpenseEditTransactionOnDelete only checks shouldRedirectDeleteToSplitExpenseEdit and childTransactions.length > 1. It never checks whether any remaining sibling split is actually unfrozen and editable. So deleteTransactions redirects straight to DynamicSplitExpenseEditPage, where canRemoveSplit is false because all sibling splits are frozen in useFrozenSplitTransactionIDs, and the Remove split button is hidden.
There are two related bugs in the same flow:
hasEditableSplitExpensesLeft checks statusNum < CONST.REPORT.STATUS_NUM.SUBMITTED instead of frozen-sibling state. That doesn't match isSplitAction (submitted splits waiting for first approval are still editable, while open reports the user can't edit are not), and redistributeRemainingPerDiemSplitExpenses overwrites frozen siblings during bulk delete instead of skipping them like redistributeExcludingFrozenSplits does.
shouldShowEditSplitInDeleteAction in ReportSecondaryActionUtils.ts and the selfDM delete check in ContextMenuActions.tsx assume Delete always opens Edit Splits, so they hide the standalone Split / Edit splits option when Delete should actually just delete the open split directly.
What changes do you think we should make in order to solve the problem?
Move getFrozenSplitTransactionIDs (resolving UNREPORTED_REPORT_ID'0' to selfDMReportID and each sibling's own parentReportID) and canRemoveSplitExpense into src/libs/SplitExpenseUtils.ts so useFrozenSplitTransactionIDs and useDeleteTransactions share the exact same logic.
In src/hooks/useDeleteTransactions.ts, gate getSplitExpenseEditTransactionOnDelete on canRemoveSplitExpense so Delete only opens Edit Splits when Remove split is actually available, and otherwise falls through to deleteMoneyRequest. For exact-sum splits (isManagedCardTransaction || isPerDiemRequest), check !frozenSplitTransactionIDs.has(...) in hasEditableSplitExpensesLeft instead of statusNum < SUBMITTED.
Export redistributeExcludingFrozenSplits from src/libs/actions/IOU/SplitExpenseItems.ts and use it in useDeleteTransactions so 3+ way bulk deletes don't overwrite frozen split amounts.
Pass shouldOpenSplitEditOnDelete into shouldShowEditSplitInDeleteAction, getSecondaryReportActions, and getSecondaryTransactionThreadActions from useExpenseActions, MoneyReportHeaderSecondaryActions, MoneyRequestHeaderSecondaryActions, and BaseReportActionContextMenu / ContextMenuActions so menu options stay in sync when Delete does a direct delete.
What alternative solutions did you explore? (Optional)
Checking statusNum < CONST.REPORT.STATUS_NUM.SUBMITTED (like the closed #106019): breaks submitted-but-unapproved splits where isSplitAction still lets you rebalance them (a plain delete breaks the exact-sum total if the report is retracted), and still dead-ends if a sibling sits on an open report the user can't split.
Hiding Delete in ContextMenuActions.tsx: doesn't let users delete an open split when the approved sibling can't absorb its amount.
📣 @kambaskovict-lang! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
⚠️@kambaskovict-lang Thanks for your interest. To be considered for this job, please post a proposal following the proposal template (note the mandatory sections). Comments claiming the job without one are not reviewed.
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Activity
applause-bot commentedon Oct 12, 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/1bc2d907f9d9b03f4cacc2f4f716e616db1561ebb19b873b0dd9778d01d9c898
MelvinBot commentedon Oct 12, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
A per diem expense is split into two expenses. One split sits in an approved report. When you delete the other split from the workspace chat context menu, the app opens the Edit split page instead of deleting it.
What is the root cause of that problem?
When you confirm Delete,
deleteTransactionsfirst checks whether it should send you to Edit split instead of deleting. That check,getSplitExpenseEditTransactionOnDelete, redirects any per diem split child on a report when the original expense has more than one split. It never checks whether the other splits can still be edited. In this case the only other split is in an approved report, so it can't be edited, but the redirect happens anyway.The same function already has the right check,
hasEditableSplitExpensesLeft. It turns the delete into a normal delete when no other split is editable. But it runs after the redirect returns early, so it never runs.The bug came from Fix unexpected error after deleting per diem split expense, which added the redirect without this check.
Code references
showDeleteModal→PopoverReportActionContextMenuconfirm →deleteTransactions→getSplitExpenseEditTransactionOnDeletereturns the transaction →initSplitExpense(..., {navigateToEditSplitExpense: true}).What changes do you think we should make in order to solve the problem?
getSplitExpenseEditTransactionOnDelete, only redirect if at least one other split is still editable. Use the same rule ashasEditableSplitExpensesLeft: the split's report is belowSUBMITTED. Move that rule into a shared helper and use it in both places. With no editable splits left, the delete falls through to the normaldeleteMoneyRequestpath.shouldOpenSplitExpenseEditFlowOnDelete, which uses the same function. They will show "Delete" again in this case without extra work.What alternative solutions did you explore? (Optional)
Make the context menu match the other menus. When the redirect applies, label the item "Edit splits" and skip the delete confirmation. Today only selfDM hides it. This fixes the confusing label but not the wrong redirect, so it should come in addition to step 1, not instead of it.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/103802)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 12, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @situchan (
External)[-]Expense - Edit split when confirming delete expense of a split per diem expense[/-][+][$175] Expense - Edit split when confirming delete expense of a split per diem expense[/+]melvin-bot commentedon Oct 12, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022109697864167641150
janiya2 commentedon Oct 12, 2026
Expensify Proposal: Issue #103802
Title:
[$175] Expense - Edit split when confirming delete expense of a split per diem expenseGitHub Issue: #103802
Assigned C+:
@situchanContributor: Janitha Dilshan (
@janiya2)Upwork Profile: https://www.upwork.com/freelancers/janithad
1. Problem Restatement
When a per-diem expense is split into multiple expenses and one split is placed in a submitted/approved report, attempting to delete the other split from the chat context menu displays a "Delete expense" confirmation dialog. However, upon confirming deletion, instead of deleting the expense (or hiding the Delete option if not allowed), the application navigates to the Edit Split Expense page where the user cannot even remove the split because the other split is frozen/approved.
2. Root Cause Analysis
There are two interrelated root causes across the data and UI layers:
Premature redirection in
getSplitExpenseEditTransactionOnDelete(useDeleteTransactions.ts:118-137):deleteTransactionschecksgetSplitExpenseEditTransactionOnDelete(transactionIDs)at line 166.getSplitExpenseEditTransactionOnDeleteonly checksshouldRedirectDeleteToSplitExpenseEditandhasMultipleSplits > 1. It does not check whether the other split expenses are still editable.(report.statusNum ?? 0) >= CONST.REPORT.STATUS_NUM.SUBMITTED), it is frozen and cannot absorb redistributed amounts.useDeleteTransactions.tsalready has the checkhasEditableSplitExpensesLeft:deleteMoneyRequestpath when no other splits can be edited. However, line 166 intercepts execution and returns early with{ action: 'redirected' }before lines 240–270 are ever reached!DynamicSplitExpenseEditPage, wherecanRemoveSplitisfalse(otherSplitExpenses.some((item) => !frozenSplitTransactionIDs.has(item.transactionID))evaluates tofalse), trapping the user on an edit page where deletion is impossible.Incomplete check in
ContextMenuActions.tsx:1768-1774:ContextMenuActions.tsx, Delete is conditionally hidden with the following comment:isSelfDM(chatReport)causes the context menu in workspace chats (and 1:1 / group chats) to show "Delete" even for active split per-diem expenses where confirming delete redirects to the Edit Split flow. Furthermore, it did not account for whether other splits are actually editable.3. Proposed Solution
A. Extract Shared Helper
hasEditableSplitExpensesinTransactionUtils/index.tsCreate a centralized helper to check if remaining child splits can be edited:
B. Guard Redirection in
useDeleteTransactions.tsUpdate
getSplitExpenseEditTransactionOnDeleteso it only redirects when at least one other split expense is editable:And replace the inline check at line 263 with
hasEditableSplitExpenses(childTransactions, allReports).C. Update Context Menu Logic in
ContextMenuActions.tsxRemove the arbitrary
isSelfDMrestriction and only hide Delete when the other splits are editable (i.e. when editing splits is the required flow):4. Alternative Solutions Considered
useDeleteTransactions.tswithout fixingContextMenuActions.tsx:5. Test Cases
Manual Tests:
Scenario 1: One split report approved, deleting remaining split (Bug Reproduction)
Scenario 2: Both split reports are open/draft
Scenario 3: Report More Menu behavior
...).Automated Unit Test:
Add a unit test in
tests/unit/useDeleteTransactionsTest.ts:haiquywork commentedon Oct 12, 2026
Proposal
What is the root cause of that problem?
getSplitExpenseEditTransactionOnDeleteinuseDeleteTransactionsdecides whether Delete should redirect to Edit split. It only checks that the transaction is a per diem split child (viashouldRedirectDeleteToSplitExpenseEdit) and that the original has more than one split. It never checks whether any other split can still be edited, so a sibling in an approved report still counts.App/src/hooks/useDeleteTransactions.ts
Lines 116 to 136 in bf69a97
deleteTransactionsthen returns early withredirectedand callsinitSplitExpensewithnavigateToEditSplitExpense, so the delete never happens.App/src/hooks/useDeleteTransactions.ts
Lines 169 to 200 in bf69a97
The Edit split flow can only work if there is another split the user can edit. The existing helper
hasEditableSplitExpenseLeft(status below SUBMITTED) encodes that rule, but the delete path does not use it.App/src/libs/actions/IOU/SplitTransactionUpdate.ts
Lines 173 to 186 in bf69a97
What changes do you think we should make in order to solve the problem?
getSplitExpenseEditTransactionOnDelete, get the child transactions withgetChildTransactions(already called) and exclude the one being deleted.statusNumbelow SUBMITTED. Reuse the rule fromhasEditableSplitExpenseLeft: map the siblings to{transactionID, reportID}and pass them withallTransactionsandallReports. Or export a small shared helper.undefinedsodeleteTransactionsruns the normal delete.shouldRedirectDeleteToSplitExpenseEditcaller inReportSecondaryActionUtils), so both paths agree.useDeleteTransactionstests: a per diem split child whose only sibling is in an approved report must returndeletedrather thanredirected. Add a second case where the sibling's report is open and the result staysredirected.What alternative solutions did you explore? (Optional)
shouldRedirectDeleteToSplitExpenseEdit: that function only takes the transaction pair and has no access to the reports, so it would need a signature change for every caller.jloa-dev commentedon Oct 13, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user confirms the deletion of a split per-diem expense whose sibling split is in a submitted or approved report, the app redirects to the "Edit split" page instead of deleting the expense.
What is the root cause of that problem?
In
src/hooks/useDeleteTransactions.ts#L116-L136,getSplitExpenseEditTransactionOnDeletechecks if the transaction being deleted is a split per diem expense:If the original transaction has more than one child split, it immediately returns the parent transaction to trigger redirection to the Edit Split flow (
navigateToEditSplitExpense).However, it fails to check whether any of the remaining sibling splits can actually be edited. If the sibling split is already in a submitted or approved report (
statusNum >= CONST.REPORT.STATUS_NUM.SUBMITTED), the Edit Split page cannot modify or remove the split, leaving the user unable to delete their expense.What changes do you think we should make in order to solve the problem?
src/hooks/useDeleteTransactions.ts, insidegetSplitExpenseEditTransactionOnDelete, filter the sibling transactions to exclude the transaction being deleted:hasEditableSplitExpenseLeft(checking ifstatusNum < CONST.REPORT.STATUS_NUM.SUBMITTED).undefined, allowingdeleteTransactionsto proceed with the normal deletion flow and removing the expense cleanly.ReportSecondaryActionUtils/ContextMenuActionsso the delete action visibility matches the executable deletion state.tests/unit/useDeleteTransactionsTest.tsto assert that deleting a split per-diem expense whose only sibling is in an approved report results in a direct deletion (deleted) rather than a redirect (redirected).What alternative solutions did you explore? (Optional)
camesenin commentedon Oct 13, 2026
melvin-bot commentedon Oct 13, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
khizzcr7 commentedon Oct 14, 2026
Hi, I'd like to work on this.
Root cause: After a per diem expense is split, deleting the second split from the workspace chat context menu navigates to the Edit split bill RHP instead of deleting. The confirm-delete path on a split child resolves to the split-edit screen because the expense is recognized as a split, so the deletion never completes and the edit page opens instead.
Fix approach:
Verification: Follow the exact repro (split a per diem expense, move the new expense to a new report, submit and approve the first report, then delete the second report from the chat and confirm) and confirm the expense is deleted and the report is removed. Also confirm the delete flow on a non-split expense is unchanged and that the Edit split page still opens correctly from a real edit action.
69 remaining items
phamdat30423 commentedon Dec 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Split a per diem expense across two reports and approve the first report. In the workspace chat, right-click the second report preview, choose Delete, and confirm. Instead of either hiding Delete or deleting safely, the app opens the Edit split page (
DynamicSplitExpenseEditPage), where Remove split is hidden because the approved sibling split cannot absorb the removed amount.What is the root cause of that problem?
Two places make inconsistent decisions about whether a per diem split child can be deleted or edited:
Workspace chat context menu leaves Delete visible even when deletion redirects or cannot succeed: In
ContextMenuActions.tsx, right-clicking a single-expense report preview resolvesactionToDeleteto the author'smoneyRequestAction(L1898), then only hides Delete for per diem split children whenisSelfDM(chatReport)is true (L1911-L1917). In workspace chat (policyExpenseChat), Delete stays visible even when every other split is frozen (isSplitExpenseFrozeninSplitExpenseUtils.ts), so per diem's exact-sum constraint makes it impossible to redistribute the amount (canRemoveSplitisfalseinDynamicSplitExpenseEditPage.tsx).useDeleteTransactionsredirects unconditionally without checking sibling report editability: InuseDeleteTransactions.ts,getSplitExpenseEditTransactionOnDeleteonly checksshouldRedirectDeleteToSplitExpenseEditandhasMultipleSplits(childTransactions.length > 1), thendeleteTransactionsimmediately opensDynamicSplitExpenseEditPageand returns{action: 'redirected'}without checking whether any surviving sibling split belongs to a report that can still absorb the amount (not frozen byisSplitExpenseFrozen/isSplitAction). Meanwhile,useDeleteReportAction.tsonly short-circuits ondeleteResult.action === 'redirected'.Reproduction Steps (1 tab):
What changes do you think we should make in order to solve the problem?
Align the menu visibility and delete execution around a single shared decision function (
delete,editSplits, orblocked):getPerDiemSplitDeleteDecisioninsrc/libs/TransactionUtils/index.tsalongsideshouldRedirectDeleteToSplitExpenseEdit):Keep existing per diem eligibility and
childTransactions.length > 1checks so ordinary expenses and the last remaining active split still evaluate to{action: 'delete'}. When multiple active splits exist, check whether any surviving sibling (child.transactionID !== transaction.transactionID) can absorb the removed amount (unreported or on an unfrozen report where!isSplitExpenseFrozen(siblingReport)):Hide Delete in
ContextMenuActions.tsxwhen the resolved action targets an un-deletable per diem split child:When
isMoneyRequestAction(actionToDelete)andiouTransactionis an active per diem split child (isExpenseSplit(iouTransaction, originalTransaction) && isPerDiemRequest(originalTransaction ?? iouTransaction)), check the child splits acrosstransactions: ifgetPerDiemSplitDeleteDecisionreturns'blocked'(or whenisSelfDM(chatReport)), returnfalseso Delete is not offered on a split whose sibling is frozen/approved. Keep Delete visible when only 1 active split remains ('delete') or when an admin is deleting the report preview itself (actionToDelete === reportAction). Also allow the workspace chat context menu to show Delete ->Edit splitsonly when an unfrozen sibling exists, or hide it cleanly whenblocked.Handle
'blocked'safely inuseDeleteTransactions.tsanduseDeleteReportAction.ts:Re-evaluate
getPerDiemSplitDeleteDecisioninsidedeleteTransactions. If the sibling report was approved while the confirmation modal was open, return{action: 'blocked'}before openingDynamicSplitExpenseEditPageor mutating the expense, and close the modal inuseDeleteReportActionwithout emittingdeletedReportAction_*:Verification:
childTransactions.length === 1) and deleting non-per-diem splits continue to delete normally.What alternative solutions did you explore? (Optional)
Deleting the draft per diem split directly when all siblings are approved would leave the remaining frozen split's total lower than the original per diem expense amount, breaking the
requiresExactSuminvariant enforced inSplitExpenseUtils.tsandDynamicSplitExpenseEditPage.tsx. Blocking deletion and hiding Delete via a shared decision helper preserves the exact-sum invariant and matches the expected behavior of not offering an impossible delete.ngocsontran208-cyber commentedon Dec 3, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-12-04 16:33:59 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a per diem expense is split across two reports and the first report is submitted and approved, right-clicking the second (draft) report preview in the workspace chat, choosing Delete, and confirming opens the Edit split page (
DynamicSplitExpenseEditPage) instead of deleting the expense—where Remove split is hidden because the approved sibling split is frozen, leaving the user stuck.Reproduction steps:
What is the root cause of that problem?
The chat context menu, the delete hook, and the split editor enforce different rules for when a per diem split child can be deleted versus edited:
Workspace chat exposes a misleading Delete confirmation for active per diem splits, while
selfDMover-hides Delete: On a single-expense report preview,ContextMenuActions.tsxresolvesactionToDeleteto the author'smoneyRequestAction, but only checksisSelfDM(chatReport)when hiding Delete for per diem split children (andBaseReportActionContextMenu.tsxonly loadschildReport's transactions, omittingoriginalTransactionand sibling splits on other reports). As a result, workspace chats show Delete + a "Delete expense" confirmation modal even when confirming redirects into Edit split, whereasselfDMhides Delete even when only one split remains or all siblings are frozen.getSplitExpenseEditTransactionOnDeleteredirects without checking whetherDynamicSplitExpenseEditPagecan remove the split: InuseDeleteTransactions.ts,getSplitExpenseEditTransactionOnDeletereturns the transaction wheneverhasMultipleSplits(> 1), causingdeleteTransactionsto openDynamicSplitExpenseEditPageearly. OnDynamicSplitExpenseEditPage.tsx, per diem requires an exact sum (requiresExactSum), socanRemoveSplitisfalsewhenever every sibling split is infrozenSplitTransactionIDs—i.e., its report is approved/settled/closed (isSplitExpenseFrozen) or!isSplitAction(...)(useFrozenSplitTransactionIDs.ts). Additionally,useFrozenSplitTransactionIDsletsitemTransaction?.reportID('0'for unreported splits) shadowitem.reportIDand fall back to another split'sfallbackReport, and passes the caller'sparentReportinstead of each sibling's own parent report.Downstream split deletion and secondary
Moremenus also diverge from the frozen-split rule: InuseDeleteTransactions.ts,hasEditableSplitExpensesLeftchecksstatusNum < SUBMITTED(which breaks submitted reports awaiting approval and misclassifies open reports the user cannot split), whileredistributeRemainingPerDiemSplitExpensesdivides the total evenly across all remaining splits—overwriting frozen approved siblings during multi-split deletions instead of usingredistributeExcludingFrozenSplits. Meanwhile,shouldShowEditSplitInDeleteActionstill hides Split ingetSecondaryReportActionsandgetSecondaryTransactionThreadActionswhen Delete no longer redirects.What changes do you think we should make in order to solve the problem?
Unify the context menu, delete pipeline, and secondary menus around the split editor's own frozen-split and removability predicates:
Extract
getFrozenSplitTransactionIDsandcanRemoveSplitExpenseintosrc/libs/SplitExpenseUtils.ts:Move the pure loop out of
useFrozenSplitTransactionIDs.tsintogetFrozenSplitTransactionIDs(typingsplitExpensesasArray<Pick<SplitExpense, 'transactionID' | 'reportID'>>, resolvingCONST.REPORT.UNREPORTED_REPORT_IDviaitem.reportID/selfDMReportIDbeforefallbackReport, and resolving each split's ownitemReport?.parentReportIDbeforeparentReport), and addcanRemoveSplitExpense:Delegate
useFrozenSplitTransactionIDsandcanRemoveSplitinDynamicSplitExpenseEditPage.tsxto these helpers.Gate redirection, fallthrough deletion, and multi-split redistribution on the shared frozen set in
src/hooks/useDeleteTransactions.tsandsrc/libs/actions/IOU/SplitExpenseItems.ts:getSplitExpenseEditTransactionOnDelete, filterotherChildTransactions(excludingtransaction.transactionID), computefrozenSplitTransactionIDs(passingselfDMReportIDandcurrentSearchResults?.data), and returnundefinedwhenotherChildTransactions.length === 0or!canRemoveSplitExpense(originalTransaction ?? transaction, otherChildTransactions, frozenSplitTransactionIDs). When every sibling is frozen (such as in an approved report),deleteTransactionsskips the redirect and deletes the draft split cleanly viadeleteMoneyRequest.deleteTransactions, computefrozenSplitTransactionIDsforchildTransactions, scope the!frozenSplitTransactionIDs.has(child.transactionID)check inhasEditableSplitExpensesLeft(L268-L271) to exact-sum splits (isPerDiemRequest/isManagedCardTransaction, keepingstatusNum < SUBMITTEDfor 1:1 IOU and regular cash splits whereisSplitActionisfalseor rebalancing does not apply), and exportredistributeExcludingFrozenSplitsfromSplitExpenseItems.tsto replaceredistributeRemainingPerDiemSplitExpenses(L70-L82, L290) so multi-select per diem deletions preserve frozen siblings while rebalancing unfrozen ones.Align chat context menu Delete visibility across all chats in
ContextMenuActions.tsxandBaseReportActionContextMenu.tsx:Add a selector-based hook
useShouldRedirectPerDiemSplitDelete(followinguseHasMultipleSplitChildren'sO(1)early exit wheneverisMini,!isVisible, oriouTransactionis not a per diem split child, so hover menus and closed popovers do zero collection work). Incommon.delete'sshouldShow, replace theisSelfDM(chatReport)-only check so Delete is hidden wheneverisMoneyRequestAction(actionToDelete)andshouldRedirectPerDiemSplitDeleteistrue(an unfrozen sibling must absorb the amount in Edit splits), and Delete is shown whenever all sibling splits are frozen or only one split remains (including inselfDM), while preserving adminREPORTPREVIEWdeletion.Preserve
Split(Edit splits) in secondaryMoremenus when Delete performs a real delete:Add an optional
shouldOpenSplitEditOnDelete?: booleanparameter toshouldShowEditSplitInDeleteAction(keeping&& isDeleteAction(...)intact so forwarded reports where Delete is hidden still offer Split),getSecondaryReportActions, andgetSecondaryTransactionThreadActionsinReportSecondaryActionUtils.ts, and pass the computedshouldShowEditSplitOnDeleteActionfromMoneyRequestHeaderSecondaryActions.tsxanduseExpenseActions.ts/MoneyReportHeaderSecondaryActions.tsx. Add unit tests covering approved, submitted-awaiting-approval, forwarded/un-splittable, self-DM, 1:1 IOU, 3-way frozen+editable redistribution, and chat context-menu scenarios.What alternative solutions did you explore? (Optional)
statusNum < CONST.REPORT.STATUS_NUM.SUBMITTED(Draft PR#106019): Rejected because splits on a submitted report awaiting approval (or viewed by an admin/manager) are still editable viaisSplitActionand not frozen, so plain-deleting them skips rebalancing and corrupts the split total upon retraction; conversely, splits on an open report the user cannot split would still redirect into a dead end.Moremenu: Hook-only proposals leaveContextMenuActions.tsxshowing a misleading "Delete expense" confirmation dialog on workspace-chat right-click when confirming opens Edit split (while over-hiding Delete inselfDMwhen sole-split or all siblings are frozen); conversely, context-menu-only proposals leaveMore,ReportDetails, bulk selection, or approved-sibling draft deletion broken.redistributeRemainingPerDiemSplitExpenses, which evenly overwrites frozen/approved sibling amounts in 3+ way per diem splits; replacing it withredistributeExcludingFrozenSplitsand scoping the!frozenSplitTransactionIDscheck inhasEditableSplitExpensesLeftto exact-sum splits protects both approved per diem siblings and 1:1 IOU / submitted cash splits.expensify-chore-bot commentedon Dec 3, 2026
@sobitneupane Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
sobitneupane commentedon Dec 4, 2026
Thanks for the proposal everyone.
Please make sure to follow the contributing guidelines
There are already 20+ proposals, and many of them seem quite similar. I would kindly request everyone to revisit their proposals and make sure they are meaningfully different from the proposals posted before.
yusufdeveloper2903 commentedon Dec 4, 2026
@sobitneupane I compared my proposal with the ones posted before it. All but one change the delete flow in
useDeleteTransactions(getSplitExpenseEditTransactionOnDelete) so the split is deleted directly when the other splits are frozen, some with a context-menu change on top. Mine leavesdeleteTransactionsand its redirect to Edit splits as they are, because removing a per diem split anywhere else breaks the exact sum, and changes only the chat context menu: the self-DM-only check becomes the same "more than one split" countdeleteTransactionsuses, so Delete is hidden in every chat exactly when confirming it would open Edit splits, which is when the More menu already shows "Edit splits" instead of Delete. The only other context-menu-only proposal adds a workspace-chat check that hides Delete only when every other split is frozen, and keeps Delete with the redirect in every other case.zeryns commentedon Dec 4, 2026
My proposal was posted at the same time as the four proposals above it. Compared with them:
Moremenu showsDeletewithoutSplitorEdit splits, so it can't be split again. Mine keepsEdit splitsthere (see the "Additionally" section)Before
Help Wanted, I also reported the regressions in Melvin's draft when the other splits are in a submitted report, and my proposal avoids themIf the product/design team would rather hide
Deletethan delete the split, my alternative covers that too, backed by the backend error for per diem split updates that don't add up and a comment from the product team hereDetails
isSplitExpenseFrozen(approved, paid or closed). A report forwarded to a second approver isn't approved yet, but a submitter who isn't an admin can't split it anymore, so the edit split page has noRemove splitthere and their fix still redirects to it. With mine,Deleteworks there (tested with two-level approval)statusNum < SUBMITTED), the same rule as Melvin's draft, so it has the same regressionsuseFrozenSplitTransactionIDslike mine. Mine also checks splits in self DM (report ID0) against the self DM report (fallbackReport). Without that, my first version showedDeleteinstead ofEdit splitsin the report header when the other split was in self DMsyedmustafan commentedon Dec 4, 2026
@sobitneupane I updated my original proposal with paired local test results. The main difference from Yusuf’s approach is that mine keeps Remove split reachable from workspace chat when the submitted sibling is still editable. Once the sibling is approved, the patch hides Delete and preserves both split amounts.
yaswar commentedon Dec 4, 2026
@sobitneupane Thanks for review!, Sharing why my unedited proposal (
2026-11-30T10:56:41Z, before the later edits and Dec 1–3 updates) is meaningfully different and avoids bugs in the earlier ones:1. Why my proposal is meaningfully different
statusNum/isSplitExpenseFrozen-only / context-menu-hide proposals either break submitted-awaiting-approval or uneditable open splits, hide Split in the More menu when Delete stops redirecting, or leave the second report undeletable.#issuecomment-7275630627(zeryns):zerynsleaveshasEditableSplitExpensesLeftchecking onlyallReportsandstatusNum < SUBMITTED, so an uneditable open sibling or Search-only approved sibling skips Edit Splits and gets rebalanced anyway. Mine aligns that fallback for per diem splits and reads Search data.fallbackReport:zerynspassessearchResultsData: undefinedandfallbackReport: selfDMReport ?? report, which marks an unloaded approved sibling as editable. Mine maps'0'toselfDMReportID, resolves each sibling's own parent report, and never falls back to another split's report.#issuecomment-7275758291(dostonbunyodov0006, plusoqildev/David-2002065):hasEditableSplitExpensesLeftwith!frozenfor all splits breaks 1:1 IOU cash splits (sinceisSplitActionreturnsfalseon non-expense reports) and silently edits submitted cash reports on bulk delete. Mine keepsstatusNum < SUBMITTEDand applies the frozen check only to per diem splits.shouldShowEditSplitInDeleteActiondropsisDeleteAction, hiding Split on forwarded reports where Delete is hidden. Mine keepsisDeleteActionintact and leavesDynamicSplitExpenseEditPage.tsxuntouched.2. Where this exact approach already exists in the app
isSplitAction+ Search snapshot check already used by Edit Splits (and tested inuseFrozenSplitTransactionIDs.test.ts):App/src/hooks/useFrozenSplitTransactionIDs.ts
Lines 47 to 72 in f3a02dc
L266–L274) that must be aligned for per diem without breaking non-per-diemIOUsplits (whereisSplitActionreturnsfalse):App/src/hooks/useDeleteTransactions.ts
Lines 266 to 274 in f3a02dc
App/src/libs/ReportSecondaryActionUtils.ts
Lines 168 to 174 in f3a02dc
Split+isDeleteActioncontract (already enforced and tested inReportSecondaryActionUtilsTest.ts):App/src/libs/ReportSecondaryActionUtils.ts
Lines 1352 to 1371 in f3a02dc
Happy to share tests or implement right away if selected!
github-actions commentedon Dec 4, 2026
kambaskovict-lang commentedon Dec 4, 2026
Proposal
What is the root cause of that problem?
In
src/hooks/useDeleteTransactions.ts,getSplitExpenseEditTransactionOnDeleteonly checksshouldRedirectDeleteToSplitExpenseEditandchildTransactions.length > 1. It never checks whether any remaining sibling split is actually unfrozen and editable. SodeleteTransactionsredirects straight toDynamicSplitExpenseEditPage, wherecanRemoveSplitisfalsebecause all sibling splits are frozen inuseFrozenSplitTransactionIDs, and the Remove split button is hidden.There are two related bugs in the same flow:
hasEditableSplitExpensesLeftchecksstatusNum < CONST.REPORT.STATUS_NUM.SUBMITTEDinstead of frozen-sibling state. That doesn't matchisSplitAction(submitted splits waiting for first approval are still editable, while open reports the user can't edit are not), andredistributeRemainingPerDiemSplitExpensesoverwrites frozen siblings during bulk delete instead of skipping them likeredistributeExcludingFrozenSplitsdoes.shouldShowEditSplitInDeleteActioninReportSecondaryActionUtils.tsand the selfDM delete check inContextMenuActions.tsxassume Delete always opens Edit Splits, so they hide the standalone Split / Edit splits option when Delete should actually just delete the open split directly.What changes do you think we should make in order to solve the problem?
getFrozenSplitTransactionIDs(resolvingUNREPORTED_REPORT_ID'0'toselfDMReportIDand each sibling's ownparentReportID) andcanRemoveSplitExpenseintosrc/libs/SplitExpenseUtils.tssouseFrozenSplitTransactionIDsanduseDeleteTransactionsshare the exact same logic.src/hooks/useDeleteTransactions.ts, gategetSplitExpenseEditTransactionOnDeleteoncanRemoveSplitExpenseso Delete only opens Edit Splits when Remove split is actually available, and otherwise falls through todeleteMoneyRequest. For exact-sum splits (isManagedCardTransaction || isPerDiemRequest), check!frozenSplitTransactionIDs.has(...)inhasEditableSplitExpensesLeftinstead ofstatusNum < SUBMITTED.redistributeExcludingFrozenSplitsfromsrc/libs/actions/IOU/SplitExpenseItems.tsand use it inuseDeleteTransactionsso 3+ way bulk deletes don't overwrite frozen split amounts.shouldOpenSplitEditOnDeleteintoshouldShowEditSplitInDeleteAction,getSecondaryReportActions, andgetSecondaryTransactionThreadActionsfromuseExpenseActions,MoneyReportHeaderSecondaryActions,MoneyRequestHeaderSecondaryActions, andBaseReportActionContextMenu/ContextMenuActionsso menu options stay in sync when Delete does a direct delete.What alternative solutions did you explore? (Optional)
statusNum < CONST.REPORT.STATUS_NUM.SUBMITTED(like the closed#106019): breaks submitted-but-unapproved splits whereisSplitActionstill lets you rebalance them (a plain delete breaks the exact-sum total if the report is retracted), and still dead-ends if a sibling sits on an open report the user can't split.ContextMenuActions.tsx: doesn't let users delete an open split when the approved sibling can't absorb its amount.melvin-bot commentedon Dec 4, 2026
📣 @kambaskovict-lang! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
kambaskovict-lang commentedon Dec 4, 2026
melvin-bot commentedon Dec 4, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
github-actions commentedon Dec 4, 2026