Skip to content

[Due for payment 2025-12-26] [$250] LHN - Duplicate Self DM chat displayed in LHN after unreporting an expense #74793

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: v9.2.48-1
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/folder/13176730/test-cases/41237113
Email or phone of affected tester (no customers): htad26+gdfdd@gmail.com
Issue reported by: Applause Internal Team
Device used: iOS 26.1/iPhone 13
App Component: Left Hand Navigation (LHN)

Action Performed:

  1. Log in to the app with a new account
  2. During on boarding, choose any onboarding intent except track expense > Finsh the flow
  3. Create a new workspace > Submit an expense to the workspace
  4. Open the expense report > Remove from report
  5. Observe LHN after the expense is moved to Self DM

Expected Result:

Self DM should be displayed only once in LHN

Actual Result:

Duplicate Self DM chats are displayed in the LHN.

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

Bug7000329_1762850610605.2025-11-11_11_21_39.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021990518500162133460
  • Upwork Job ID: 1990518500162133460
  • Last Price Increase: 2025-11-17
Issue OwnerCurrent Issue Owner: @CortneyOfstad

Activity

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

    @melvin-bot

    Triggered auto assignment to @CortneyOfstad (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. dmkt9 commented on Nov 11, 2025

    @dmkt9
    Contributor

    Proposal

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

    Duplicate Self DM chats are displayed in the LHN.

    What is the root cause of that problem?

    1. A new optimistic selfDM chat is created if it doesn't already exist:

      if (!existingSelfDMReportID && reportID === CONST.REPORT.UNREPORTED_REPORT_ID) {
      const currentTime = DateUtils.getDBTime();
      selfDMReport = buildOptimisticSelfDMReport(currentTime);

    2. However, when CHANGE_TRANSACTIONS_REPORT succeeds, the server returns a selfDM chat with a new reportID, resulting in two selfDM chats.

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

    We should remove the optimistic selfDM chat regardless of whether CHANGE_TRANSACTIONS_REPORT succeeds or fails.

    // Add success data for self DM report
    successData.push(
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`,
    value: {
    pendingFields: {
    createChat: null,
    },
    },
    },
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${selfDMReport.reportID}`,
    value: {isOptimisticReport: false},
    },
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`,
    value: {
    [selfDMCreatedReportAction.reportActionID]: {
    pendingAction: null,
    },
    },
    },
    );
    // Add failure data for self DM report
    failureData.push(
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`,
    value: null,
    },
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${selfDMReport.reportID}`,
    value: null,
    },
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`,
    value: null,
    },
    );

    finallyData.push(
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`,
            value: null,
        },
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${selfDMReport.reportID}`,
            value: null,
        },
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`,
            value: null,
        },
    );

    failureData,

            failureData,
    +       finallyData,

    What alternative solutions did you explore? (Optional)

    N/A

  4. nkdengineer commented on Nov 11, 2025

    @nkdengineer
    Contributor

    Proposal

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

    Duplicate Self DM chats are displayed in the LHN.

    What is the root cause of that problem?

    A selfDM is created in optimistic data and then the backend returns another selfDM with the different reportID

    if (!existingSelfDMReportID && reportID === CONST.REPORT.UNREPORTED_REPORT_ID) {
    const currentTime = DateUtils.getDBTime();
    selfDMReport = buildOptimisticSelfDMReport(currentTime);

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

    Define a new parameter selfDMReportID and set it as the optimistic selfDM's reportID. Then the backend will use this to generate the selfDM report. With this we can ensure the optimistic selfDM and the report is created from the backend is the same.

    We can also define selfDMCreatedReportActionID for the created action of the selfDM like we do when deleting the app report

    App/src/libs/actions/Report.ts

    Lines 5092 to 5096 in 48f5093

    const parameters: DeleteAppReportParams = {
    reportID,
    transactionIDToReportActionAndThreadData: JSON.stringify(transactionIDToReportActionAndThreadData),
    selfDMReportID: selfDMParameters.reportID,
    selfDMCreatedReportActionID: selfDMParameters.createdReportActionID,

    selfDMReportID: report === CONST.REPORT.UNREPORTED_REPORT_ID && !existingSelfDMReportID ? selfDMReport?.reportID : undefined,
    

    const parameters: ChangeTransactionsReportParams = {

    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.

  5. melvin-bot commented on Nov 15, 2025

    @melvin-bot

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

  6. CortneyOfstad commented on Nov 17, 2025

    @CortneyOfstad
    Contributor

    Getting eyes!

  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 17, 2025
  8. melvin-bot commented on Nov 17, 2025

    @melvin-bot
  9. changed the title [-]LHN - Duplicate Self DM chat displayed in LHN after unreporting an expense[/-] [+][$250] LHN - Duplicate Self DM chat displayed in LHN after unreporting an expense[/+] on Nov 17, 2025
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Nov 17, 2025
  11. 48 remaining items

  12. nkdengineer commented on Dec 17, 2025

    @nkdengineer
    Contributor

    @bernhardoj The PR is ready for review.

  13. bernhardoj commented on Dec 17, 2025

    @bernhardoj
    Contributor

    Just a note that the PR was reverted because of an issue that happens after this PR is merged on the same day as our PR.

  14. changed the title [-][Due for payment 2025-12-23] [$250] LHN - Duplicate Self DM chat displayed in LHN after unreporting an expense[/-] [+][Due for payment 2025-12-26] [$250] LHN - Duplicate Self DM chat displayed in LHN after unreporting an expense[/+] on Dec 22, 2025
  15. CortneyOfstad commented on Dec 22, 2025

    @CortneyOfstad
    Contributor

    Due to the regression, the new payment date is set for 12/26. The team will be OoO for the holidays, but I will be working 12/29, so will get that paid then 👍

    @bernhardoj can you make sure the checklist is completed before that time? Thanks!

  16. bernhardoj commented on Dec 23, 2025

    @bernhardoj
    Contributor

    BugZero Checklist:

    • [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: N/A - I think this is more likely caused by a BE change. Before, if there is no self DM report found, then it means the report doesn't exist on the BE, too. But now, the self DM is always created on the BE, but the FE could not have the self DM report data, and only have the self DM report ID.

    • [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: N/A

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

    N/A

    Test:

    1. Log in to the app with a new account
    2. During onboarding, choose any onboarding intent except track expense > Finish the flow
    3. Create a new workspace if there is no workspace yet
    4. Submit an expense to the workspace
    5. Open the expense report
    6. Press the Report field > Remove from report
    7. Verify there is no duplicate self DM in LHN

    Do we agree 👍 or 👎

  17. melvin-bot commented on Dec 26, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@CortneyOfstad)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1990518500162133460/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  18. CortneyOfstad commented on Dec 29, 2025

    @CortneyOfstad
    Contributor

    Payment Summary

    @bernhardoj — to be paid $250 via NewDot
    @nkdengineer — to be paid $250 via NewDot

    Regression Test

    https://github.com/Expensify/Expensify/issues/582613

  19. bernhardoj commented on Dec 30, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  20. garrettmknight commented on Jan 5, 2026

    @garrettmknight
    Contributor

    $250 approved for @bernhardoj

  21. twisterdotcom commented on Jan 12, 2026

    @twisterdotcom
    Contributor

    @nkdengineer has submitted payment for this report on ND here.

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

    Zapier Logs Run ID: 00040eee-52a2-a763-a28b-a4dcedd35914
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 contributorReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions