Skip to content

[Due for payment 2026-10-14] [$175] [Exploratory] Per Diem - Expense fails to revert to original after removing split in SelfDM #100130

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.66-0
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/test-runs/71924520/folder/53991585/110878718/1717129043?sort=%2Bidentifier
Email or phone of affected tester (no customers): leungbratt6+02096@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 10/Chrome
App Component: Chat Report View

Action Performed:

Preconditions: User has created 2 Per Diem expenses in Workspace chat

  1. Open the New Dot app
  2. Navigate to Workspace chat - Delete the report
  3. Go to selfDM and locate the per diem expense
  4. Click on one of the per diem -> More -> Split -> Save
  5. Click on one of the splits - More - Edit split - Remove split
  6. Repeat the same step on another split per diem

Expected Result:

Split Per Diem expense reverts to the original Per Diem

Actual Result:

Nothing happen

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7248708_1788331318969.per_diem.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7248708

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit

Activity

  1. applause-bot commented on Sep 2, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/61ebcf09a932d498ecee5f6219723d9136dc95c13f53404609fe3911d10b3640

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 24, 2026
  3. MelvinBot commented on Sep 24, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    "Remove split" never saves anything — it only edits a local draft. The revert to the original per diem is a separate API call that only fires when you press Save on the split overview screen afterwards.

    src/pages/iou/DynamicSplitExpenseEditPage.tsx:551-564 calls removeSplitExpenseField and navigates back. That function filters the split out of the array, redistributes amounts, and does exactly one Onyx.merge into splitTransactionDraft_<originalTransactionID>. There is no API.write, no optimistic data, no transaction change. The real revert is RevertSplitTransaction, reached only via Save → updateSplitTransactionsFromSplitExpensesFlow → isReverseSplitOperation → SplitTransactionUpdate.ts:2012-2019.

    Why only per diem hits this. Per diem is the only expense type whose split child's Delete is rerouted into this draft-edit screen. shouldRedirectDeleteToSplitExpenseEdit returns false unless the source transaction is per diem, and returns true unconditionally for a selfDM per-diem split. When it's true, the More menu relabels Delete as "Edit splits" (MoneyRequestHeaderSecondaryActions.tsx:545-553) and drops you on the split-edit RHP. For every other type, Delete really deletes and the split collapses on its own. So per diem is the only type where "undo this split" lands on a screen whose only destructive button is a draft edit needing a second, unadvertised Save — which matches the repro steps exactly (step 4 says "Save", step 5 does not).

    Investigation details, two secondary defects, and what I could not verify

    The last split can never be removed. The button is gated on Number(splitExpensesList?.length) > 1, so with 2 splits you can remove one, and the remaining one has no Remove button. That's intentional — 1 split is the revert — but it only materialises on Save.

    Secondary defect 1 (selfDM-only, confirmed). SplitTransactionUpdate.ts:310 reads reportActions_${revertSplitTransaction?.reportID}, but a selfDM split child's reportID is '0' (UNREPORTED_REPORT_ID), so the lookup always misses. splitTransactionThreadReportID stays undefined and the comment-migration block gated at line 1924 is dead code for every selfDM reverse split — comments on the split thread are silently lost. The same file already does the correct mapping at lines 1391-1393.

    Secondary defect 2 (per-diem data loss). buildOptimisticTransaction only writes comment.customUnit for distance transactions or when pendingFields.subRates is set. Neither split-draft builder sets it — the "already split" branch at SplitExpenses.ts:116-130 passes no customUnit at all — so per-diem split drafts lose subRates, customUnitID and attributes.dates, and stop being detectable as per diem by isPerDiemRequest. redistributeSplitExpenseAmounts then rewrites amount without touching subRates, leaving the survivor with 100% of the total but the parent's full per-diem breakdown. There is no per-diem branch anywhere in SplitExpenseItems.ts — every branch is isDistanceRequest vs. everything-else — and the three split test suites have zero per-diem coverage.

    Alternative explanations I ruled out. The per-diem save gate at DynamicSplitExpensePage.tsx:327-335 blocks Save on a customUnitOutOfPolicy violation, but deleteAppReport clears violations when the workspace report is deleted, and the same gate would have blocked step 4's Save. The Onyx merge key in removeSplitExpenseField is correct in the selfDM case — resolveSplitItemReportID maps '0' back to the real selfDM report ID. Onyx.merge replaces arrays rather than merging them, so the filtered array does take effect.

    Not verified. I could not reproduce this or view the attached video (sandboxed), so I can't confirm the tester never pressed Save versus Save firing and silently failing. Two things would settle it: whether RevertSplitTransaction was ever issued for this transaction, and whether the client logged [Split] Can't find the report action for transaction (SplitTransactionUpdate.ts:1405).

    What changes do you think we should make in order to solve the problem?

    1. Make Remove split terminal when it produces a revert. In DynamicSplitExpenseEditPage.tsx:551, when removing leaves exactly one split and child transactions already exist, commit the revert immediately via the same reverse-split path Save uses, rather than only writing the draft. If we'd rather keep Save as the commit point, the edit screen must at minimum return to the overview with a visible unsaved-state cue, because today the screen looks identical before and after.
    2. Fix the selfDM report-action lookup at SplitTransactionUpdate.ts:310 to map UNREPORTED_REPORT_ID to the selfDM report ID, matching lines 1391-1393.
    3. Carry customUnit through per-diem split drafts so subRates/customUnitID/attributes.dates survive, and give removeSplitExpenseField/redistributeSplitExpenseAmounts a per-diem branch so a redistributed amount doesn't contradict the sub-rates. Add per-diem cases to the split test suites, which currently have none.

    What alternative solutions did you explore? (Optional)

    • Drop the per-diem redirect entirely — remove the isPerDiemRequest special case in shouldRedirectDeleteToSplitExpenseEdit so Delete on a per-diem split behaves like every other type. Simplest fix for the reported symptom, but it discards whatever the redirect was added for.
    • Rename the button and add a confirmation ("Remove and save"). Cheapest, but leaves defects 2 and 3 in place.

    Related issues

    Neither looks like a duplicate.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/100130) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 24, 2026
  5. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @linhvovan29546 (External)

  6. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. linhvovan29546 commented on Sep 25, 2026

    @linhvovan29546
    Contributor

    @MelvinBot implement this

  8. MelvinBot commented on Sep 25, 2026

    @MelvinBot
    Contributor

    🤖 Draft PR created: Revert a per diem split right away when removing a split leaves only one
    Please mark it as "Ready for review" when it is ready for review.

    What changed: On a per diem expense that is already split, Remove split now reverts the expense to the original right away when only one split would be left. Before, you also had to press Save on the split overview. The revert uses the same save path as the overview's Save, which now lives in a shared useSaveSplitExpenses hook.

    What's different from the proposal:

    • Step 2 (selfDM report-action lookup): dropped. A unit test showed that the remaining selfDM split thread's comments already move during a revert, through another code path. Adding the lookup could move them twice.
    • Step 3 (keeping customUnit/subRates in per diem drafts): not included. The reported bug doesn't need it, so it can be a separate follow-up.

    Testing: Typecheck, lint, formatting, spell check, and the React Compiler check all pass. The related Jest suites pass (178 of 178), including a new test. I didn't test the flow in a browser because the test account has no workspace with per diem rates. You still need to fill in the Tests and QA sections.

  9. linhvovan29546 commented on Sep 25, 2026

    @linhvovan29546
    Contributor

    MelvinBot proposal LGTM!

    🎀 👀 🎀 C+ reviewed

  10. 22 remaining items

  11. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Oct 8, 2026
  12. melvin-bot commented on Oct 13, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  13. melvin-bot commented on Oct 13, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  14. melvin-bot commented on Oct 16, 2026

    @melvin-bot

    @mallenexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

  15. mallenexpensify commented on Oct 16, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @linhvovan29546 due $175 via NewDot

  16. twisterdotcom commented on Nov 17, 2026

    @twisterdotcom
    Contributor

    $175 approved for @linhvovan29546 in Report ID: R00YISUXxump.

    Zapier Logs Run ID: 00040eee-6f67-aedc-9532-5f423b038224

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNot a priority

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions