[$175] Expense - Edit split when confirming delete expense of a split per diem expense
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
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): [email protected] 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
Workaround:
Unknown
Platforms:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/b5c6abaa-bb90-44d6-a5e3-98cbe3f9b63c
Applause Internal Information Exported by: Svetlana Lazutkina Bug ID: 7284598
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022109697864167641150
- Upwork Job ID: 2109697864167641150
- Last Price Increase: 2026-10-12
Issue Owner
Current Issue Owner: @sobitneupane
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
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, 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.
The bug came from Fix unexpected error after deleting per diem split expense, which added the redirect without this check.
Code references
- Redirect condition with no editability check: src/hooks/useDeleteTransactions.ts:129-136
- Early return that opens Edit split: src/hooks/useDeleteTransactions.ts:166-198
- Existing check that never runs here: src/hooks/useDeleteTransactions.ts:263-271
- Context menu Delete only hides per diem splits in selfDM, and always shows the delete confirmation: src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx:1766-1799
- Path: context menu Delete →
showDeleteModal→PopoverReportActionContextMenuconfirm →deleteTransactions→getSplitExpenseEditTransactionOnDeletereturns 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 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. - 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.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @situchan (External)
Job added to Upwork: https://www.upwork.com/jobs/~022109697864167641150
Expensify Proposal: Issue #103802
Title: [$175] Expense - Edit split when confirming delete expense of a split per diem expense
GitHub Issue: https://github.com/Expensify/App/issues/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,
deleteTransactionschecksgetSplitExpenseEditTransactionOnDelete(transactionIDs)at line 166. - Currently,
getSplitExpenseEditTransactionOnDeleteonly checksshouldRedirectDeleteToSplitExpenseEditandhasMultipleSplits > 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 checkhasEditableSplitExpensesLeft:
This fallback was specifically engineered to delete the expense via the standardconst hasEditableSplitExpensesLeft = childTransactions.some((childTransaction) => { const currentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${childTransaction?.reportID}`]; return (currentReport?.statusNum ?? 0) < CONST.REPORT.STATUS_NUM.SUBMITTED; }); if (!hasEditableSplitExpensesLeft) { nonSplitTransactions.push(...splitTransactionsByOriginalTransactionID[transactionID]); continue; }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! - Consequently, the user is redirected to
DynamicSplitExpenseEditPage, wherecanRemoveSplitisfalse(otherSplitExpenses.some((item) => !frozenSplitTransactionIDs.has(item.transactionID))evaluates tofalse), trapping the user on an edit page where deletion is impossible.
- When a user confirms deletion of a split expense,
-
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). const chatReport = getReportOrDraftReport(reportIDParam); if (isSelfDM(chatReport) && iouTransaction) { const originalTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${iouTransaction.comment?.originalTransactionID}`]; if (isExpenseSplit(iouTransaction, originalTransaction) && isPerDiemRequest(originalTransaction ?? iouTransaction)) { return false; } } - 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.
- In
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:
--- a/src/libs/TransactionUtils/index.ts
+++ b/src/libs/TransactionUtils/index.ts
@@ -1516,6 +1516,18 @@ function shouldRedirectDeleteToSplitExpenseEdit(transaction: OnyxEntry<Transacti
return !isExpenseUnreported(transaction ?? undefined) && !isExpenseUnreported(originalTransaction ?? undefined);
}
+function hasEditableSplitExpenses(
+ childTransactions: Transaction[],
+ allReports: OnyxCollection<Report>,
+ excludedTransactionID?: string,
+): boolean {
+ const remainingSplits = excludedTransactionID ? childTransactions.filter((child) => child?.transactionID !== excludedTransactionID) : childTransactions;
+ return remainingSplits.some((childTransaction) => {
+ const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${childTransaction?.reportID}`];
+ return (report?.statusNum ?? 0) < CONST.REPORT.STATUS_NUM.SUBMITTED;
+ });
+}
+
/**
* Return transactions pending action.
*/
B. Guard Redirection in useDeleteTransactions.ts
Update getSplitExpenseEditTransactionOnDelete so it only redirects when at least one other split expense is editable:
--- a/src/hooks/useDeleteTransactions.ts
+++ b/src/hooks/useDeleteTransactions.ts
@@ -21,6 +21,7 @@ import {
getChildTransactions,
getOriginalTransactionWithSplitInfo,
+ hasEditableSplitExpenses,
isPerDiemRequest as isPerDiemRequestTransactionUtils,
isSplitChildTransaction,
shouldRedirectDeleteToSplitExpenseEdit,
@@ -131,8 +132,9 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransa
const isSelfDMSplit = isSelfDM(report) || (!!selfDMReportID && transaction.reportID === CONST.REPORT.UNREPORTED_REPORT_ID);
- const hasMultipleSplits = getChildTransactions(allTransactions, originalTransaction?.transactionID).length > 1;
- if (!shouldRedirectDeleteToSplitExpenseEdit(transaction, originalTransaction, isSelfDMSplit) || (!hasMultipleSplits && isPerDiemRequestTransactionUtils(originalTransaction))) {
+ const childTransactions = getChildTransactions(allTransactions, originalTransaction?.transactionID);
+ const hasMultipleSplits = childTransactions.length > 1;
+ if (!shouldRedirectDeleteToSplitExpenseEdit(transaction, originalTransaction, isSelfDMSplit) || (!hasMultipleSplits && isPerDiemRequestTransactionUtils(originalTransaction))) {
return undefined;
}
+ if (!hasEditableSplitExpenses(childTransactions, allReports, transaction.transactionID)) {
+ return undefined;
+ }
+
return transaction;
};
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.tswithout fixingContextMenuActions.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.
5. Test Cases
Manual Tests:
-
Scenario 1: One split report approved, deleting remaining split (Bug Reproduction)
- Enable Per Diem in Workspace settings.
- Create a Per Diem expense on Report A.
- Open Report A > More > Split > Confirm.
- Move the newly created split expense to Report B.
- 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')
});
Proposal
What is the root cause of that problem?
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.
https://github.com/Expensify/App/blob/bf69a97dab592f475ad199d9a30e00eecb525301/src/hooks/useDeleteTransactions.ts#L116-L136
deleteTransactions then returns early with redirected and calls initSplitExpense with navigateToEditSplitExpense, so the delete never happens.
https://github.com/Expensify/App/blob/bf69a97dab592f475ad199d9a30e00eecb525301/src/hooks/useDeleteTransactions.ts#L169-L200
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.
https://github.com/Expensify/App/blob/bf69a97dab592f475ad199d9a30e00eecb525301/src/libs/actions/IOU/SplitTransactionUpdate.ts#L173-L186
What changes do you think we should make in order to solve the problem?
- In
getSplitExpenseEditTransactionOnDelete, get the child transactions withgetChildTransactions(already called) and exclude the one being deleted. - Redirect only if at least one remaining sibling's report has
statusNumbelow SUBMITTED. Reuse the rule fromhasEditableSplitExpenseLeft: map the siblings to{transactionID, reportID}and pass them withallTransactionsandallReports. Or export a small shared helper. - If none are editable, return
undefinedsodeleteTransactionsruns the normal delete.
const otherSplits = getChildTransactions(allTransactions, originalTransaction?.transactionID)
.filter((child) => child.transactionID !== transaction.transactionID);
const hasEditableOtherSplit = hasEditableSplitExpenseLeft(otherSplits.map(toSplitExpense), allTransactions, allReports, undefined);
if (!hasEditableOtherSplit) {
return undefined;
}
- Apply the same check where the context-menu delete visibility is decided (
shouldRedirectDeleteToSplitExpenseEditcaller inReportSecondaryActionUtils), so both paths agree. - Add a unit test to
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)
- 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.
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, getSplitExpenseEditTransactionOnDelete checks if the transaction being deleted is a split per diem expense:
if (!shouldRedirectDeleteToSplitExpenseEdit(transaction, originalTransaction)) {
return undefined;
}
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, insidegetSplitExpenseEditTransactionOnDelete, filter the sibling transactions to exclude the transaction being deleted:
const otherSplits = getChildTransactions(allTransactions, originalTransaction?.transactionID)
.filter((child) => child.transactionID !== transaction.transactionID);
- Verify if any remaining sibling is editable using the existing logic from
hasEditableSplitExpenseLeft(checking ifstatusNum < CONST.REPORT.STATUS_NUM.SUBMITTED). - If no other editable split exists, return
undefined, allowingdeleteTransactionsto proceed with the normal deletion flow and removing the expense cleanly. - Align
ReportSecondaryActionUtils/ContextMenuActionsso the delete action visibility matches the executable deletion state. - Add unit tests in
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)
- Disabling the Delete option entirely when a sibling split is approved: rejected because it prevents users from deleting legitimate orphan expenses on open reports.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When attempting to delete a split child expense of a per diem transaction, the application incorrectly redirects the user to the "Edit Split" flow even when sibling split expenses belong to submitted or approved reports that can no longer be edited, causing the user to become stuck unable to complete the deletion.
What is the root cause of that problem?
When deleting a child split expense of a per diem transaction, useDeleteTransactions.ts:133 calls shouldRedirectDeleteToSplitExpenseEdit(transaction, originalTransaction, isSelfDMSplit).
Currently, this check only evaluates whether the transactions are reported and whether multiple split children exist (childTransactions.length > 1), but it fails to inspect whether the remaining split children belong to reports that are still in an editable/draft state.
When one of the split reports has already been submitted or approved (report.statusNum >= CONST.REPORT.STATUS_NUM.SUBMITTED), the split cannot be modified on the Edit Split page. Redirecting the user to the Edit Split flow traps them in a workflow where the remaining split cannot be edited or removed.
What changes do you think we should make in order to solve the problem?
- In
src/libs/TransactionUtils/index.ts: Add helperhasEditableSplitExpenses(childTransactions, allReports, excludedTransactionID): Verify whether any remaining sibling child transaction belongs to a report with(report?.statusNum ?? 0) < CONST.REPORT.STATUS_NUM.SUBMITTED. - In
src/hooks/useDeleteTransactions.ts: IngetSplitExpenseEditTransactionOnDelete, guard the redirection: if!hasEditableSplitExpenses(childTransactions, allReports, transaction.transactionID), returnundefinedso that the expense is deleted directly rather than redirecting to Edit Split. - In
src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx: Ensure context menu actions align with the same check, so Delete is only hidden when remaining splits are genuinely editable. - Add unit test in
tests/unit/useDeleteTransactionsTest.ts: Verify that deleting a split per-diem transaction directly executes deletion when sibling splits are on submitted/approved reports.
What alternative solutions did you explore? (Optional)
None. Modifying the redirection guard directly in useDeleteTransactions ensures consistent deletion behavior across both report view and chat context menus.
Contributor details Your Expensify account email: [email protected] Upwork Profile link: https://www.upwork.com/freelancers/~0170d6b02e9440e604
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
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:
- 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.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01c5c6bc0e7d162f7b
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!
@situchan Still overdue 6 days?! Let's take care of this!
@situchan 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
@situchan 10 days overdue. I'm getting more depressed than Marvin.
@situchan 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!
@situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!
@situchan Eep! 4 days overdue now. Issues have feelings too...
@situchan Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!