Skip to content

[Due for payment 2025-05-27] [$250] Delete & Hold are present when there are two expense previews, app crashes with Hold option #61448

Closed

Description

@mitarachim

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.1.40-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): applausetester+smidod11s1j@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Log in with Expensifail account.
  1. Go to staging.new.expensify.com
  2. Go to 1:1 DM.
  3. Submit two expenses to th euser.
  4. Click on the expense preview.
  5. Click on any expense.
  6. Send a message in the transaction thread.
  7. Click on the report header.
  8. Click Delete expense.
  9. Delete the expense.
  10. Close the RHP.
  11. Now back in the expense report. click More.
  12. Click Delete.
  13. Note that nothing happens after tapping Delete.
  14. Click More.
  15. Click Hold.
  16. Now app crashes with the Hold option.

Expected Result:

In Step 13 and 16, Hold and Delete option should not appear in More options because the expense report has two expense previews - one of the expense previews is present as "Deleted expense" because the expense has a comment.

Actual Result:

In Step 13 and 16, Hold and Delete option are present in More options when the expense report has two expense previews.
In Step 13, nothing happens with Delete option.
In Step 16, app crashes with Hold option.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6822777_1746511204158.20250506_135306.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021919796257257842653
  • Upwork Job ID: 1919796257257842653
  • Last Price Increase: 2025-05-06
  • Automatic offers:
    • brunovjk | Reviewer | 107218744
    • thelullabyy | Contributor | 107218746
Issue OwnerCurrent Issue Owner: @lschurr

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 6, 2025
  2. melvin-bot commented on May 6, 2025

    @melvin-bot

    Triggered auto assignment to @lschurr (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. nkdengineer commented on May 6, 2025

    @nkdengineer
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    In Step 13 and 16, Hold and Delete option are present in More options when the expense report has two expense previews.
    In Step 13, nothing happens with Delete option.
    In Step 16, app crashes with Hold option.

    What is the root cause of that problem?

    After we delete the transaction, it will set the transaction to null

    It leads to reportTransactions has only 1 transaction => isHoldAction and isDeleteAction will be true

    if (isHoldAction(report, reportTransactions)) {
    options.push(CONST.REPORT.SECONDARY_ACTIONS.HOLD);
    }

    if (isDeleteAction(report, reportTransactions)) {
    options.push(CONST.REPORT.SECONDARY_ACTIONS.DELETE);
    }

    const isOneExpenseReport = reportTransactions.length === 1;

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

    We should add the condition like we did with ContextMenuActions component

    textTranslateKey: 'iou.hold',
    icon: Expensicons.Stopwatch,
    shouldShow: ({type, moneyRequestAction, areHoldRequirementsMet}) =>
    type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION && areHoldRequirementsMet && canHoldUnholdReportAction(moneyRequestAction).canHoldRequest,

    textTranslateKey: 'reportActionContextMenu.deleteAction',
    icon: Expensicons.Trashcan,
    shouldShow: ({type, reportAction, isArchivedRoom, isChronosReport, reportID, moneyRequestAction}) =>
    // Until deleting parent threads is supported in FE, we will prevent the user from deleting a thread parent
    !!reportID &&
    type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION &&
    canDeleteReportAction(moneyRequestAction ?? reportAction, isMoneyRequestAction(moneyRequestAction) ? getOriginalMessage(moneyRequestAction)?.IOUReportID : reportID) &&

    1. Add a new variable parentAction to getSecondaryReportActions function here and pass requestParentReportAction

    return getSecondaryReportActions(moneyRequestReport, transactions, violations, policy);

    1. Using canHoldUnholdReportAction instead of isHoldAction and use canDeleteReportAction instead of isDeleteAction

    Note: we can do the same with other action

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 6, 2025
  5. changed the title [-]Delete & Hold are present when there are two expense previews, app crashes with Hold option[/-] [+][$250] Delete & Hold are present when there are two expense previews, app crashes with Hold option[/+] on May 6, 2025
  6. melvin-bot commented on May 6, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 6, 2025
  8. melvin-bot commented on May 6, 2025

    @melvin-bot

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

  9. thelullabyy commented on May 7, 2025

    @thelullabyy
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    In Step 13, nothing happens with Delete option.
    In Step 16, app crashes with Hold option.

    What is the root cause of that problem?

    if (isHoldAction(report, reportTransactions)) {
    options.push(CONST.REPORT.SECONDARY_ACTIONS.HOLD);
    }

    if (isDeleteAction(report, reportTransactions)) {
    options.push(CONST.REPORT.SECONDARY_ACTIONS.DELETE);
    }

    Both isHoldAction and isDeleteAction action don't cover this case because the deleted transaction will be removed

    const isSingleTransaction = reportTransactions.length === 1;

    const isOneExpenseReport = reportTransactions.length === 1;

    --> Both variables will be true

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

    We need to implement another way to verify that there is only one transaction. We must use both transactions and reportAction to detect it.

    function isHoldAction(report: Report, reportTransactions: Transaction[]): boolean {

    
    // reportActionscould be added to isHoldAction as a new param
        const transactionThreadReportID = getOneTransactionThreadReportID(report.reportID, reportActions ?? []);
    
        const isOneExpenseReport = reportTransactions.length === 1;
        const transaction = reportTransactions.at(0);
    
        if (!transactionThreadReportID || !isOneExpenseReport || !transaction) {
            return false;
        }
    
    

    Also, apply the same way to other actions

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    I suggest adding UTs for both isHoldAction and isDeleteAction function and covering 3 main cases

    • There are two transactions
    • There is one transaction
    • there are two transactions but one of them has been removed

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  10. brunovjk commented on May 7, 2025

    @brunovjk
    Contributor

    Thanks everyone for the proposals! 🙏 Both solutions worked in my initial tests, and the RCAs are quite similar.

    I think we can move forward with @nkdengineer's proposal — it aligns well with the current code structure and makes the dependency on parentReportID explicit, improving clarity and maintainability.

    🎀👀🎀 C+ reviewed

  11. melvin-bot commented on May 7, 2025

    @melvin-bot

    Triggered auto assignment to @francoisl, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  12. 8 remaining items

  13. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on May 20, 2025
  14. changed the title [-][$250] Delete & Hold are present when there are two expense previews, app crashes with Hold option[/-] [+][Due for payment 2025-05-27] [$250] Delete & Hold are present when there are two expense previews, app crashes with Hold option[/+] on May 20, 2025
  15. melvin-bot commented on May 20, 2025

    @melvin-bot

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

  16. melvin-bot commented on May 20, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.46-12 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 2025-05-27. 🎊

    For reference, here are some details about the assignees on this issue:

  17. melvin-bot commented on May 20, 2025

    @melvin-bot

    @brunovjk @lschurr @brunovjk 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. brunovjk commented on May 26, 2025

    @brunovjk
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/58084/files#r2107702286

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Precondition:

    • Log in with Expensifail account, or with beta permissions enabled.

    Test:

    1. Open the App
    2. Go to 1:1 DM.
    3. Submit two expenses to th euser.
    4. Click on the expense preview.
    5. Click on any expense.
    6. Send a message in the transaction thread.
    7. Click on the report header.
    8. Click Delete expense.
    9. Delete the expense.
    10. Close the RHP.
    11. Now back in the expense report. click More.
    12. Verify Hold and Delete not appear in More options

    Do we agree 👍 or 👎

  19. lschurr commented on May 27, 2025

    @lschurr
    Contributor

    Payment summary:

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 contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions