Skip to content

[hold for 76511] [$250] Endless loading when delete Per diem expense from Self DM chat #75660

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.2.61-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-2027/folder/13176674/41236543/1026028414
Email or phone of affected tester (no customers): gocemate+b2155558@gmail.com
Issue reported by: Applause Internal Team
Device used: Lenovo 80ES / Windows 10 Pro
App Component: Money Requests

Action Performed:

Precondition: User have Per diem expense created

  1. Go to workspace chat and open the per diem expense
  2. Click on report> remove from report
  3. Verify you land on Self DM chat
  4. Right click on expense> delete

Expected Result:

Expense should be deleted

Actual Result:

Expense report loading infinitely

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/~021991988960980010582
  • Upwork Job ID: 1991988960980010582
  • Last Price Increase: 2025-11-28

Activity

  1. added
    Daily
    Bug
    on Nov 20, 2025
  2. melvin-bot commented on Nov 20, 2025

    @melvin-bot

    Triggered auto assignment to @joekaufmanexpensify (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. melvin-bot commented on Nov 20, 2025

    @melvin-bot

    📣 @fireball37hbn! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  4. joekaufmanexpensify commented on Nov 21, 2025

    @joekaufmanexpensify
    Contributor

    Reproduced

  5. added
    External
    on Nov 21, 2025
  6. changed the title [-]Endless loading when delete Per diem expense from Self DM chat[/-] [+][$250] Endless loading when delete Per diem expense from Self DM chat[/+] on Nov 21, 2025
  7. melvin-bot commented on Nov 21, 2025

    @melvin-bot
  8. added
    Help Wanted
    on Nov 21, 2025
  9. melvin-bot commented on Nov 21, 2025

    @melvin-bot

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

  10. marufsharifi commented on Nov 23, 2025

    @marufsharifi
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-11-28 16:26:45 UTC.

    Proposal

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

    Deleting an expense after moving it to the self DM can get stuck in an infinite loading state because a duplicate self DM is created and the user may land in the wrong one.

    What is the root cause of that problem?

    In changeTransactionsReport (moving to personal), when no self-DM exists we create an optimistic self-DM. We weren’t passing the optimistic self-DM identifiers back to the backend. The backend’s normal pattern is to receive selfDMReportID + selfDMCreatedReportActionID and then send Onyx that clears the temporary self-DM. Without those IDs, the optimistic self-DM lingers as a duplicate, leading to the stuck delete when users are in the wrong chat.

    • In changeTransactionsReport we look up a self DM; if none is found, we create an optimistic one:
      if (!existingSelfDMReportID && reportID === CONST.REPORT.UNREPORTED_REPORT_ID) {
      const currentTime = DateUtils.getDBTime();
      selfDMReport = buildOptimisticSelfDMReport(currentTime);
      selfDMCreatedReportAction = buildOptimisticCreatedReportAction(email ?? '', currentTime);
      // Add optimistic updates for self DM report
      optimisticData.push(
      {
      onyxMethod: Onyx.METHOD.SET,
      key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`,
      value: {
      ...selfDMReport,
      pendingFields: {
      createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
      },
      },
      },
      {
      onyxMethod: Onyx.METHOD.MERGE,
      key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${selfDMReport.reportID}`,
      value: {isOptimisticReport: true},
      },
      {
      onyxMethod: Onyx.METHOD.SET,
      key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`,
      value: {
      [selfDMCreatedReportAction.reportActionID]: selfDMCreatedReportAction,
      },
      },
      );
    • But when we call the API, we only send the transaction mapping, not the optimistic self-DM identifiers, so the backend can’t clear it:
      const parameters: ChangeTransactionsReportParams = {
      transactionList: transactionIDs.join(','),
      reportID,
      transactionIDToReportActionAndThreadData: JSON.stringify(transactionIDToReportActionAndThreadData),
      };
      API.write(WRITE_COMMANDS.CHANGE_TRANSACTIONS_REPORT, parameters, {
      optimisticData,
      successData,
      failureData,
      });

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

    We just need to pass the optimistic self-DM identifiers to the backend when we create one. The code changes are minimal:

    • Capture the optimistic self-DM IDs when we have to create it:
      if (!existingSelfDMReportID && reportID === CONST.REPORT.UNREPORTED_REPORT_ID) {
      const currentTime = DateUtils.getDBTime();
      selfDMReport = buildOptimisticSelfDMReport(currentTime);
      selfDMCreatedReportAction = buildOptimisticCreatedReportAction(email ?? '', currentTime);
      // Add optimistic updates for self DM report
      optimisticData.push(
      {
      onyxMethod: Onyx.METHOD.SET,
      key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`,
      value: {
      ...selfDMReport,
      pendingFields: {
      createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
      },
      },
      },
      {
      onyxMethod: Onyx.METHOD.MERGE,
      key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${selfDMReport.reportID}`,
      value: {isOptimisticReport: true},
      },
      {
      onyxMethod: Onyx.METHOD.SET,
      key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`,
      value: {
      [selfDMCreatedReportAction.reportActionID]: selfDMCreatedReportAction,
      },
      },
      );
    // In changeTransactionsReport, when no self DM exists
    const currentTime = DateUtils.getDBTime();
    selfDMReport = buildOptimisticSelfDMReport(currentTime);
    selfDMCreatedReportAction = buildOptimisticCreatedReportAction(email ?? '', currentTime);
    // Track them so we can send to BE
    +selfDMParameters = {
    +    reportID: selfDMReport.reportID,
    +    createdReportActionID: selfDMCreatedReportAction.reportActionID,
    +};
    • Include those IDs in the API call so the backend can clear the optimistic chat:
    const parameters: ChangeTransactionsReportParams = {
        transactionList: transactionIDs.join(','),
        reportID,
        transactionIDToReportActionAndThreadData: JSON.stringify(transactionIDToReportActionAndThreadData),
    +    ...(selfDMParameters.reportID && selfDMParameters.createdReportActionID
    +        ? {
    +              selfDMReportID: selfDMParameters.reportID,
    +              selfDMCreatedReportActionID: selfDMParameters.createdReportActionID,
    +          }
    +        : {}),
    };
    
    API.write(WRITE_COMMANDS.CHANGE_TRANSACTIONS_REPORT, parameters, {
        optimisticData,
        successData,
        failureData,
    });

    If any further FE tweaks or changes are needed during implementation, I’m happy to handle them.

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

    • When creating an optimistic self DM, the success path removes the optimistic self DM (report, metadata, actions) after the API call.
    • The failure path also clears the optimistic self DM.
    • No duplicate self DM persists in Onyx after changeTransactionsReport completes.

    What alternative solutions did you explore? (Optional)

  11. 23 remaining items

  12. ahmedGaber93 commented on Dec 5, 2025

    @ahmedGaber93
    Contributor

    @joekaufmanexpensify I will be OOO for the next 3 weeks. Please reassign this if needed. Thanks!

  13. joekaufmanexpensify commented on Dec 8, 2025

    @joekaufmanexpensify
    Contributor

    Will do! I'll reassign this if we end up needing frontend changes here and you're still OOO when it comes time to address those.

  14. joekaufmanexpensify commented on Dec 15, 2025

    @joekaufmanexpensify
    Contributor

    Still held

  15. joekaufmanexpensify commented on Dec 19, 2025

    @joekaufmanexpensify
    Contributor

    Held

  16. c3024 commented on Dec 29, 2025

    @c3024
    Contributor

    Still on hold!

  17. joekaufmanexpensify commented on Jan 5, 2026

    @joekaufmanexpensify
    Contributor

    Still held

  18. joekaufmanexpensify commented on Jan 12, 2026

    @joekaufmanexpensify
    Contributor

    Still held

  19. joekaufmanexpensify commented on Jan 19, 2026

    @joekaufmanexpensify
    Contributor

    @c3024 I see #76511 was closed without merging. What does that mean for this issue?

  20. c3024 commented on Jan 20, 2026

    @c3024
    Contributor

    This is not reproducible anymore. We can close this.

  21. marufsharifi commented on Jan 21, 2026

    @marufsharifi
    Contributor

    Not reproducible for me too

  22. c3024 commented on Jan 26, 2026

    @c3024
    Contributor

    Not reproducible anymore.

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

Metadata

Metadata

Labels

BugExternalWeekly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions