Skip to content

[Due for payment 2025-08-20] [$250] mWeb- LHN - Double chat messages when move expense to other workspace #65561

Closed

Description

@jponikarchuk

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: v9.1.77-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: #65310
Email or phone of affected tester (no customers): gocemate+b2153682approver@gmail.com
Issue reported by: Applause Internal Team
Device used: Samsung Galaxy A02s/12
App Component: Left Hand Navigation (LHN)

Action Performed:

Precondition:

  1. Create a workspace with Admin, Approver and Member.

Steps

  1. Go to the app
  2. [Member] Submit an expense in the workspace chat.
  3. [Member] Click Submit on the expense preview.
  4. [Approver] Create a new workspace.
  5. [Approver] Open workspace chat with member.
  6. [Approver] Open the expense report.
  7. [Approver] Click More > Change workspace.
  8. [Approver] Select the new workspace.
  9. [Approver] Open the workspace chat with member from Step 5.

Expected Result:

There should be only one message " User owes..."

Actual Result:

Double chat messages when move expense to other workspace

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

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021942581813581610068
  • Upwork Job ID: 1942581813581610068
  • Last Price Increase: 2025-07-15
  • Automatic offers:
    • truph01 | Contributor | 108079583
Issue OwnerCurrent Issue Owner: @DylanDylann

Activity

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

    @melvin-bot

    Triggered auto assignment to @sonialiap (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. truph01 commented on Jul 7, 2025

    @truph01
    Contributor

    Proposal

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

    • Duplicate chat messages appear when an expense is moved to another workspace.

    What is the root cause of that problem?

    • When changing the workspace, we have logic here:

      App/src/libs/actions/Report.ts

      Lines 5575 to 5586 in 46b6aef

      // 3. Optimistically create a new REPORT_PREVIEW reportAction with the newReportPreviewActionID
      // and set it as a parent of the moved report
      const policyExpenseChat = getPolicyExpenseChat(currentUserAccountID, policyID);
      const optimisticReportPreviewAction = buildOptimisticReportPreview(policyExpenseChat, report);
      const newPolicyExpenseChatReportID = policyExpenseChat?.reportID;
      optimisticData.push({
      onyxMethod: Onyx.METHOD.MERGE,
      key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${newPolicyExpenseChatReportID}`,
      value: {[optimisticReportPreviewAction.reportActionID]: optimisticReportPreviewAction},
      });

    This logic creates a new REPORT_PREVIEW report action and adds it to the policy expense chat. However, we are always adding it to the current user's policy expense chat, instead of the policy expense chat of the user who owns the expense report (optimistically).

    • Meanwhile, the backend also creates a new REPORT_PREVIEW report action, but it correctly adds it to the policy expense chat of the actual owner of the expense report.

    • As a result, the "User owes..." message appears twice in the LHN.

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

    Introduce a third parameter: optimisticPolicyExpenseChatReport?: Report. This will help handle two cases:

    1. When the policy expense chat hasn’t been created yet.
    2. When the policy expense chat has already been created.
    • Then, update the logic here:

      App/src/libs/actions/Report.ts

      Lines 5575 to 5580 in 46b6aef

      // 3. Optimistically create a new REPORT_PREVIEW reportAction with the newReportPreviewActionID
      // and set it as a parent of the moved report
      const policyExpenseChat = getPolicyExpenseChat(currentUserAccountID, policyID);
      const optimisticReportPreviewAction = buildOptimisticReportPreview(policyExpenseChat, report);
      const newPolicyExpenseChatReportID = policyExpenseChat?.reportID;

    Update it as follows:

    
        // 3. Optimistically create a new REPORT_PREVIEW reportAction with the newReportPreviewActionID
        // and set it as a parent of the moved report
        const policyExpenseChat = optimisticPolicyExpenseChatReport ?? getPolicyExpenseChat(report.ownerAccountID, policyID);
        const optimisticReportPreviewAction = buildOptimisticReportPreview(policyExpenseChat, report);
    
        const newPolicyExpenseChatReportID = policyExpenseChat?.reportID;
    
    1. In:
      } = buildOptimisticChangePolicyData(report, policyID);

      pass membersChats.reportCreationData[submitterEmail] as 3rd param.

    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)

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 8, 2025
  5. changed the title [-]mWeb- LHN - Double chat messages when move expense to other workspace[/-] [+][$250] mWeb- LHN - Double chat messages when move expense to other workspace[/+] on Jul 8, 2025
  6. melvin-bot commented on Jul 8, 2025

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

    @melvin-bot

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

  9. melvin-bot commented on Jul 11, 2025

    @melvin-bot

    @DylanDylann Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  10. sonialiap commented on Jul 15, 2025

    @sonialiap
    Contributor

    @DylanDylann have you had a chance to review the proposal?

  11. 23 remaining items

  12. melvin-bot commented on Aug 13, 2025

    @melvin-bot

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

  13. melvin-bot commented on Aug 13, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.93-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 2025-08-20. 🎊

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

  14. melvin-bot commented on Aug 13, 2025

    @melvin-bot

    @DylanDylann / @truph01 @sonialiap 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]

  15. sonialiap commented on Aug 22, 2025

    @sonialiap
    Contributor

    Payment summary:

  16. DylanDylann commented on Aug 25, 2025

    @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: Feature: Implement ChangeReportPolicy #57553 (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:https://github.com/Expensify/Expensify/issues/540281

    Regression Test Proposal

    Precondition:

    • Create a workspace with Admin, Approver and Member

    Test:

    1. [Member] Submit an expense in the workspace chat.
    2. [Member] Click Submit on the expense preview.
    3. [Approver] Create a new workspace.
    4. [Approver] Open workspace chat with member.
    5. [Approver] Open the expense report.
    6. [Approver] Click More > Change workspace.
    7. [Approver] Select the new workspace.
    8. [Approver] Open the workspace chat with member from Step 5.
    9. There should be only one message " User owes..."

    Do we agree 👍 or 👎

  17. garrettmknight commented on Oct 24, 2025

    @garrettmknight
    Contributor

    $250 approved for @DylanDylann

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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions