Skip to content

[HOLD for payment 2024-12-11] [$250] Held expense - Empty message with reply appears after paying the unheld amount for second time #52696

Closed

Description

@IuliiaHerets

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.0.63-3
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): applausetester+kh051115@applause.expensifail.com
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. [User A] Submit two expenses to User B.
  3. [User B] Hold the first expense.
  4. [User B] Click Pay button and pay the unheld amount.
  5. [User A] Submit another expense to User B.
  6. [User B] Go to the expense report.
  7. [User B] Click Pay button and pay the unheld amount.
  8. [User B] Note that the held expense is marked as paid when it should be moved to another report.
  9. [User B] Refresh the expense report.
  10. [User B] Note that there is an empty message with reply which opens the held expense when clicked.

Expected Result:

In Step 8, the held expense should move to another report when only the pending amount is paid.
In Step 10, after refreshing the page, there should not be an empty message in the expense report.

Actual Result:

In Step 8, the held expense does not move to another report when only the pending amount is paid. The expense preview is marked as paid when only the unheld amount is paid.

In Step 10, after refreshing the page, there is an empty message in the expense report, which opens the held expense.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6668237_1731920941849.bandicam_2024-11-18_17-00-07-546.mp4

Bug6668237_1731920941852!bandicam_2024-11-18_17-01-57-378

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021859730399211188082
  • Upwork Job ID: 1859730399211188082
  • Last Price Increase: 2024-11-21
  • Automatic offers:
    • DylanDylann | Reviewer | 105075616
Issue OwnerCurrent Issue Owner: @johncschuster

Activity

  1. added
    Daily
    Bug
    on Nov 18, 2024
  2. melvin-bot commented on Nov 18, 2024

    @melvin-bot

    Triggered auto assignment to @johncschuster (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. bernhardoj commented on Nov 19, 2024

    @bernhardoj
    Contributor

    Proposal

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

    The hold report action isn't removed from the paid expense chat and becomes empty when revisiting the report.

    What is the root cause of that problem?

    When we pay the expense report with held expense, it will optimistically remove the held expense and move it to the new optimistic expense report.

    App/src/libs/actions/IOU.ts

    Lines 6309 to 6331 in f77087f

    holdReportActions.forEach((holdReportAction) => {
    const originalMessage = ReportActionsUtils.getOriginalMessage(holdReportAction);
    deleteHoldReportActions[holdReportAction.reportActionID] = {
    message: [
    {
    deleted: DateUtils.getDBTime(),
    type: CONST.REPORT.MESSAGE.TYPE.TEXT,
    text: '',
    },
    ],
    };
    const reportActionID = rand64();
    addHoldReportActions[reportActionID] = {
    ...holdReportAction,
    reportActionID,
    originalMessage: {
    ...originalMessage,
    IOUReportID: optimisticExpenseReport.reportID,
    },
    pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
    };

    But the issue started to happen when we did it again the second time. It's because when we optimistically add the held expense to a new expense report, we set the pending action to add (as shown above). But we don't clear it when the request is successful. So, the pending action is always true and when we optimistically delete it, it will still be shown because a pending action is always shown.

    const isDeleted = isDeletedAction(reportAction);
    const isPending = !!reportAction.pendingAction;
    return !isDeleted || isPending || isDeletedParentAction(reportAction) || isReversedTransaction(reportAction);

    It becomes an empty message when we reopen it because the BE response changes the action to ADDCOMMENT instead of IOU.

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

    We need to clear the pending action when the request is successful.

    const successAddHoldReportActions = {};
    
    holdReportActions.forEach((holdReportAction) => {
    
    const reportActionID = rand64();
    addHoldReportActions[reportActionID] = {
        ...
        pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
    };
    
    successAddHoldReportActions[reportActionID] = {
        pendingAction: null,
    };
    

    We might need to do it for the optimistic report preview too because it also adds a pending action when created optimistically.

    App/src/libs/actions/IOU.ts

    Lines 6295 to 6302 in f77087f

    const optimisticExpenseReportPreview = ReportUtils.buildOptimisticReportPreview(
    chatReport,
    optimisticExpenseReport,
    '',
    firstHoldTransaction,
    optimisticExpenseReport.reportID,
    newParentReportActionID,
    );

    We can do the same with other optimistic data that I missed.

  4. added
    External
    on Nov 21, 2024
  5. melvin-bot commented on Nov 21, 2024

    @melvin-bot
  6. changed the title [-]Held expense - Empty message with reply appears after paying the unheld amount for second time[/-] [+][$250] Held expense - Empty message with reply appears after paying the unheld amount for second time[/+] on Nov 21, 2024
  7. added
    Help Wanted
    on Nov 21, 2024
  8. melvin-bot commented on Nov 21, 2024

    @melvin-bot

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

  9. melvin-bot commented on Nov 25, 2024

    @melvin-bot

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

  10. 22 remaining items

  11. melvin-bot commented on Dec 4, 2024

    @melvin-bot

    @DylanDylann @johncschuster @DylanDylann 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]

  12. johncschuster commented on Dec 4, 2024

    @johncschuster
    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:

    • [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 Template
    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Test:

    Do we agree 👍 or 👎

  13. johncschuster commented on Dec 6, 2024

    @johncschuster
    Contributor

    Payment Summary:

    Contributor: @bernhardoj due $250 via NewDot
    Contributor+: @DylanDylann paid $250 via Upwork

    Upwork job here! Please apply

  14. bernhardoj commented on Dec 6, 2024

    @bernhardoj
    Contributor

    Requested in ND.

  15. added
    Daily
    and removed
    Weekly
    on Dec 10, 2024
  16. moved this from Bugs and Follow Up Issues to Hold for Payment in #expensify-bugson Dec 10, 2024
  17. JmillsExpensify commented on Dec 11, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  18. johncschuster commented on Dec 11, 2024

    @johncschuster
    Contributor

    Payment has been issued through Upwork. Thanks, everyone, for your contributions!

  19. moved this from Hold for Payment to Done in #expensify-bugson Dec 11, 2024
  20. johncschuster commented on Dec 11, 2024

    @johncschuster
    Contributor

    Oh wait, I jumped the gun. @DylanDylann, can you please post the regression test steps if applicable?

  21. DylanDylann commented on Dec 11, 2024

    @DylanDylann
    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: Create optimistic report when approving/paying for report with hold expenses #42573 (comment)

    • [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.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Test:

    1. Open a workspace chat
    2. Submit 2 money requests
    3. Open the expense report
    4. Hold one of the expenses
    5. Pay the report partially
    6. Verify the held expense is removed
    7. Go back to workspace chat
    8. Open the new expense report
    9. Submit another money request
    10. Pay the report partially
    11. Verify the held expense is removed

    Do we agree 👍 or 👎

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions