Skip to content

[Due for payment 2026-01-30] [$125] Expense - Self DM appears twice in Recents section after deleting two empty reports #78606

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: 9.2.89-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/test-runs/TR-2581/folder/13176730/41237110/1099719633
Email or phone of affected tester (no customers): isjdsoijsojnsiojisndj@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.1 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com
  2. Log in with new account.
  3. Create a workspace.
  4. Go to workspace chat.
  5. Create two empty reports.
  6. Delete both empty reports.
  7. Open FAB > Start chat.

Expected Result:

Self DM will not appear in Recents section after deleting reports.

Actual Result:

Self DM appears twice in Recents section after deleting two empty reports.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022007151481601471722
  • Upwork Job ID: 2007151481601471722
  • Last Price Increase: 2026-01-14
  • Automatic offers:
    • daledah | Contributor | 110108198
Issue OwnerCurrent Issue Owner: @garrettmknight

Activity

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

    @melvin-bot

    Triggered auto assignment to @garrettmknight (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. daledah commented on Dec 30, 2025

    @daledah
    Contributor

    Proposal

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

    Self DM appears twice in Recents section after deleting two empty reports.

    What is the root cause of that problem?

    We have the cache for the self DM report ID here

    App/src/libs/ReportUtils.ts

    Lines 1208 to 1212 in ae4cd7c

    let cachedSelfDMReportID: OnyxEntry<string>;
    Onyx.connectWithoutView({
    key: ONYXKEYS.SELF_DM_REPORT_ID,
    callback: (value) => (cachedSelfDMReportID = value),
    });

    App/src/libs/ReportUtils.ts

    Lines 1876 to 1879 in ae4cd7c

    function findSelfDMReportID(): string | undefined {
    if (cachedSelfDMReportID) {
    return cachedSelfDMReportID;
    }

    The first time we delete a report, we create the selfDM report onyx data here

    App/src/libs/actions/Report.ts

    Lines 4965 to 4973 in ae4cd7c

    let selfDMReportID = findSelfDMReportID();
    let selfDMReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`];
    let createdAction: ReportAction;
    let selfDMParameters: SelfDMParameters = {};
    if (!selfDMReport) {
    const currentTime = DateUtils.getDBTime();
    selfDMReport = buildOptimisticSelfDMReport(currentTime);
    selfDMReportID = selfDMReport.reportID;

    But we not update the ONYXKEYS.SELF_DM_REPORT_ID => On the second deletion attempt, selfDMReport was still undefined=> We create another new selfDM report.

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

    We should change ONYXKEYS.SELF_DM_REPORT_ID when we create the self DM report.

                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.SELF_DM_REPORT_ID}`,
                    value: selfDMReportID,
                },
    

    optimisticData.push(

    Alternatively, we could add a flag to avoid using the cache in this case.

        function findSelfDMReportID(shouldUseCache: boolean = true): string | undefined {
            if (shouldUseCache && cachedSelfDMReportID) {
                return cachedSelfDMReportID;
            }
    

    App/src/libs/ReportUtils.ts

    Lines 1876 to 1879 in ae4cd7c

    function findSelfDMReportID(): string | undefined {
    if (cachedSelfDMReportID) {
    return cachedSelfDMReportID;
    }

    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. samranahm commented on Dec 30, 2025

    @samranahm
    Contributor

    Proposal

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

    Expense - Self DM appears twice in Recents section after deleting two empty reports

    What is the root cause of that problem?

    When deleting multiple empty reports quickly, each deletion would call deleteAppReport, which would check for an existing Self DM using findSelfDMReportID(). When the first deletion created a new Self DM, it was only added to the optimistic data, not to the cached ONYXKEYS.SELF_DM_REPORT_ID. So when the second deletion happened immediately after, findSelfDMReportID() still returned undefined because:

    • The cache cachedSelfDMReportID was not updated
    • The first Self DM was in optimistic data, not in allReports yet

    This caused two separate Self DM reports to be created.

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

    We should add an Onyx.merge call to update ONYXKEYS.SELF_DM_REPORT_ID right after creating a new Self DM report in deleteAppReport

    if (!selfDMReport) {
        const currentTime = DateUtils.getDBTime();
        selfDMReport = buildOptimisticSelfDMReport(currentTime);
        selfDMReportID = selfDMReport.reportID;
        createdAction = buildOptimisticCreatedReportAction(currentUserEmailParam ?? '', currentTime);
        selfDMParameters = {reportID: selfDMReport.reportID, createdReportActionID: createdAction.reportActionID};
        
        // Update the cached Self DM report ID to prevent duplicate Self DM creation
        Onyx.merge(ONYXKEYS.SELF_DM_REPORT_ID, selfDMReport.reportID);

    here

    App/src/libs/actions/Report.ts

    Lines 4971 to 4976 in 8d19e95

    if (!selfDMReport) {
    const currentTime = DateUtils.getDBTime();
    selfDMReport = buildOptimisticSelfDMReport(currentTime);
    selfDMReportID = selfDMReport.reportID;
    createdAction = buildOptimisticCreatedReportAction(currentUserEmailParam ?? '', currentTime);
    selfDMParameters = {reportID: selfDMReport.reportID, createdReportActionID: createdAction.reportActionID};

    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. paulnjs commented on Dec 31, 2025

    @paulnjs
    Contributor

    Proposal

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

    Expense - Self DM appears twice in Recents section after deleting two empty reports

    What is the root cause of that problem?

    When users delete the report, we’ll find the selfDMReportID and selfDMReport

    App/src/libs/actions/Report.ts

    Lines 4965 to 4966 in ae4cd7c

    let selfDMReportID = findSelfDMReportID();
    let selfDMReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`];

    selfDMReportID will be read from selfDMReportID Onyx data and it always has value, but for the new account, selfDMReport is undefined. If it’s undefined, we’ll create the new one and send to BE with reportID and createdReportActionID

    After delete the first report, we already create the new selfDMReport, but we didn’t pass the selfDMReportID to buildOptimisticCreatedReportAction so it’ll generate the new report with different reportID from selfDMReportID

    selfDMReport = buildOptimisticSelfDMReport(currentTime);

    That why selfDMReport is still undefined after deleting the first one.

    We shouldn’t generate the new selfDMReportID because BE will throw the error when we try to send the message on that report

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

    Update this line

    selfDMReport = buildOptimisticSelfDMReport(currentTime);

    To

           selfDMReport = buildOptimisticSelfDMReport(currentTime, selfDMReportID);
    

    What alternative solutions did you explore? (Optional)

    N/A

    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.

  6. bernhardoj commented on Dec 31, 2025

    @bernhardoj
    Contributor

    Proposal

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

    Dupe self dm report shows in start chat page after deleting 2 empty reports.

    What is the root cause of that problem?

    When we delete a report, we will create an optimistic self dm report if it doesn't exist yet on the FE.

    App/src/libs/actions/Report.ts

    Lines 4965 to 4986 in 1d1ea3d

    let selfDMReportID = findSelfDMReportID();
    let selfDMReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`];
    let createdAction: ReportAction;
    let selfDMParameters: SelfDMParameters = {};
    if (!selfDMReport) {
    const currentTime = DateUtils.getDBTime();
    selfDMReport = buildOptimisticSelfDMReport(currentTime);
    selfDMReportID = selfDMReport.reportID;
    createdAction = buildOptimisticCreatedReportAction(currentUserEmailParam ?? '', currentTime);
    selfDMParameters = {reportID: selfDMReport.reportID, createdReportActionID: createdAction.reportActionID};
    optimisticData.push(
    {
    onyxMethod: Onyx.METHOD.SET,
    key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`,
    value: {
    ...selfDMReport,
    pendingFields: {
    createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
    },
    },
    },

    We check whether it exists by getting the report based on the ID from findSelfDMReportID, which returns the ID from selfDMReportID onyx key. However, every user already has a self dm report on the BE. So, when we delete the empty report twice, we create 2 optimistic reports because each optimistic report has a different reportID.

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

    First, we need to pass the self DM report ID from findSelfDMReportID when creating the optimistic report so the optimistic report is created with the same reportID we have on the BE.

    selfDMReport = buildOptimisticSelfDMReport(currentTime, selfDMReportID);

    Next, we need to remove the optimistic created action, otherwise we will have 2 created actions on the report. We will also remove the selfDMParameters as it's unused now. The end result will look like this:

    let selfDMReportID = findSelfDMReportID();
    let selfDMReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`];
    
    if (!selfDMReport) {
        const currentTime = DateUtils.getDBTime();
        selfDMReport = buildOptimisticSelfDMReport(currentTime, selfDMReportID);
        selfDMReportID = selfDMReport.reportID;
        optimisticData.push(
            {
                onyxMethod: Onyx.METHOD.SET,
                key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`,
                value: selfDMReport,
            },
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${selfDMReport.reportID}`,
                value: {
                    isOptimisticReport: false,
                },
            },
        );
    }

    NOTE: we can optionally only create the self DM report if the report that we delete contains transaction because when it's an empty report, the DeleteAppReport API doesn't return the self DM report data as the response.

  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jan 2, 2026
  8. melvin-bot commented on Jan 2, 2026

    @melvin-bot
  9. changed the title [-]Expense - Self DM appears twice in Recents section after deleting two empty reports[/-] [+][$250] Expense - Self DM appears twice in Recents section after deleting two empty reports[/+] on Jan 2, 2026
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 2, 2026
  11. 52 remaining items

  12. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jan 23, 2026
  13. changed the title [-][$125] Expense - Self DM appears twice in Recents section after deleting two empty reports[/-] [+][Due for payment 2026-01-30] [$125] Expense - Self DM appears twice in Recents section after deleting two empty reports[/+] on Jan 23, 2026
  14. melvin-bot commented on Jan 23, 2026

    @melvin-bot

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

  15. melvin-bot commented on Jan 23, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.7-3 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-01-30. 🎊

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

  16. melvin-bot commented on Jan 23, 2026

    @melvin-bot

    @rojiphil @garrettmknight 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]

  17. garrettmknight commented on Jan 31, 2026

    @garrettmknight
    Contributor

    Payment Summary

    • Contributor: @daledah paid $125 via Upwork
    • Contributor+: @rojiphil due $125 via NewDot
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