Skip to content

[Due for payment 2026-04-14] Expense - Extra hold expense comment appears after splitting held expense #86798

Closed

Description

@nlemma

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.51-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #84551
Email or phone of affected tester (no customers): snodijosdnjoijiosnj@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Chat Report View

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create an expense.
  4. Open the expense.
  5. Hold the expense.
  6. Click More > Split > Save.
  7. Open any held split expense.

Expected Result:

Only one hold expense comment will appear in the transaction thread.

Actual Result:

Extra hold expense comment appears after splitting held expense.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7118376_1774988078805.12.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 31, 2026
  2. melvin-bot commented on Mar 31, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #84551

  3. melvin-bot commented on Mar 31, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Mar 31, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. OSBotify commented on Mar 31, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #84551 - "Fix/73390 - Split Transaction - Reply link is shown after deleting an expense" by @dmkt9 (High confidence)
    Related Issues: #73390

    Recommendation: REVERT

    This PR introduced logic to copy comments and hold state when splitting transactions. The bug occurs in the copyCommentsAndHoldState function where duplicate hold comments are created when splitting a held expense.

    Labels: No changes needed. DeployBlockerCash is correctly applied (blocks App deploy for this frontend bug).

    📋 Detailed Analysis

    Evidence

    Verification

    The bug affects the split transaction functionality in:

    • File: src/libs/actions/IOU/Split.ts
    • Function: copyCommentsAndHoldState (lines 1587-1628)

    I confirmed that PR #84551 modified this exact file, adding 408 additions and 109 deletions to src/libs/actions/IOU/Split.ts.

    Root Cause

    The bug is in lines 1623-1627 of Split.ts:

    // If the commentAction is not found, it means the action has been deleted.
    // We call insertHoldState here to ensure the hold state is always added.
    if (!hasInsertedHoldState) {
        insertHoldState();
    }

    The problem: When splitting a held expense, the code iterates through comment actions to find the hold comment action (lines 1614-1618). If the hold comment action is not found in the iteration (due to filtering, timing issues, or timestamp mismatches in the isHoldComment comparison), the fallback logic at line 1626 calls insertHoldState() without a comment action parameter.

    This creates a hold report action WITHOUT the associated comment. However, the original hold state/comment may still exist or be added elsewhere, resulting in duplicate hold comments appearing in the transaction thread.

    Expected behavior: Only ONE hold expense comment should appear
    Actual behavior: Extra hold expense comment appears after splitting held expense

  6. luacmartins commented on Mar 31, 2026

    @luacmartins
    Contributor

    @dmkt9 can you please take a look at this?

  7. MelvinBot commented on Mar 31, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    PR #84551 added comment-copying logic to src/libs/actions/IOU/Split.ts so that when a transaction is split, comments from the original thread are carried over to each split transaction's thread. For held expenses, the code also copies the hold state (HOLD action + hold reason comment) to each split.

    The problem is in the isHoldComment matching function at src/libs/actions/IOU/Split.ts:1607-1612. When a transaction is held, two report actions are created in the thread:

    1. A HOLD action (type HOLD) — the system marker
    2. An ADDCOMMENT action — the hold reason text, created 1ms after the HOLD

    The comment-copying code at line 1172-1174 collects all ADDCOMMENT actions from the original thread (including the hold reason). The copyCommentsAndHoldState function (line 1587-1628) iterates over these comments and uses isHoldComment to detect which ADDCOMMENT is the hold reason, so it can intercept it and create a proper HOLD+comment pair in the split thread instead of copying it as a regular comment.

    isHoldComment identifies the hold comment by matching timestamps between the HOLD action and each ADDCOMMENT:

    • If holdReportAction.timestamp is defined (server data): compares holdReportAction.timestamp === commentAction.timestamp
    • If undefined (optimistic data): checks if commentAction.created - 1ms === holdReportAction.created

    This matching is fragile. When it fails (e.g., server-returned timestamp values differ between the HOLD action and its paired ADDCOMMENT, or one has timestamp defined while the other doesn't), the hold reason ADDCOMMENT is not intercepted. It falls through to addCommentToSplitTransactionThread (line 1620) and gets copied as a regular comment. Then, after the loop, the fallback at line 1625-1626 calls insertHoldState() without a comment argument, creating a HOLD action with no paired comment.

    The split thread then contains:

    1. A HOLD action ("held this expense") — from the fallback insertHoldState()
    2. The hold reason text as a separate regular comment — from addCommentToSplitTransactionThread

    This appears to the user as an extra hold comment in the split transaction thread.

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

    Make the isHoldComment matching more robust in src/libs/actions/IOU/Split.ts. Instead of relying solely on exact timestamp comparison, the function should:

    1. First try the existing timestamp comparison (when both actions have timestamp defined)
    2. If only one has timestamp defined, fall through to the created comparison instead of returning false
    3. For the created comparison, use a small window (e.g., within 2 seconds) rather than requiring an exact 1ms gap, since server-assigned created values may not preserve the client-side 1ms offset

    Specifically, update isHoldComment at line 1607-1612 to handle the case where the HOLD action has timestamp but the ADDCOMMENT doesn't (or vice versa) by falling back to the created-based comparison. Also widen the created comparison to check if commentAction.created is within a small time window after holdReportAction.created, rather than requiring exactly 1ms difference.

    What alternative solutions did you explore? (Optional)

    An alternative approach would be to filter the hold reason ADDCOMMENT out of allCommentActionsFromOriginalTransactionThread before the copying loop, using the originalTransaction.comment.hold field to identify the HOLD action and then finding its paired ADDCOMMENT. However, this would require a separate mechanism to identify the paired comment and would be more complex.

    Another option would be to add an explicit flag or property to hold reason ADDCOMMENT actions (e.g., a isHoldReasonComment field) so they can be identified reliably without timestamp matching. This would require changes to both buildOptimisticHoldReportActionComment in ReportUtils.ts and the backend.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  8. dmkt9 commented on Apr 1, 2026

    @dmkt9
    Contributor

    @luacmartins I just checked and the HoldRequest API no longer returns the timestamp field for the two reportActions (HOLD and ADDCOMMENT). At the same time, the created values of these two reportActions have also changed compared to optimisticData (they are no longer offset by 1ms). As a result, both checks fail, and the comment ends up being treated as a normal comment, which leads to incorrect params when splitting the transaction.

    Are we removing the timestamp field from those reportActions on the backend?

  9. 9 remaining items

  10. added a commit that references this issue on Apr 3, 2026
  11. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  12. luacmartins commented on Apr 7, 2026

    @luacmartins
    Contributor

    This is fixed

  13. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Apr 7, 2026
  14. changed the title [-]Expense - Extra hold expense comment appears after splitting held expense[/-] [+][Due for payment 2026-04-14] Expense - Extra hold expense comment appears after splitting held expense[/+] on Apr 7, 2026
  15. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  16. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.53-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-04-14. 🎊

  17. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    @luacmartins The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  18. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

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.EngineeringWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions