Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.56k stars 2.9k forks source link

IOU-Expense is not deleted in the expense details if there is a comment inside the expense #49052

Closed IuliiaHerets closed 2 months ago

IuliiaHerets commented 2 months ago

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.33-1 Reproducible in staging?: Y Reproducible in production?: N If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4952443 Email or phone of affected tester (no customers): testpayment935@gmail.com Issue reported by: Applause Internal Team

Action Performed:

  1. (User A) - Create two IOUs in a 1:1 conversation to user B
  2. (User B) - Create two IOUs in a 1:1 conversation to user A
  3. (User A) - Navigate to the IOU transaction thread of the expense submitted by user B
  4. (User A) - Send some messages to B's expense
  5. (User B) -Navigate to the IOU transaction thread of the expense submitted by user A
  6. (User B) - Send some messages to user A's expense
  7. (User B) - Go back and open your expense
  8. (User B) - Click on the header of your own expense
  9. (User B) - Click on Delete Expense

Expected Result:

The expense should be deleted.

Actual Result:

The expense is not deleted.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/3bad72e6-3e75-4b74-bbcb-8e86bbceaafb

View all open jobs on GitHub

melvin-bot[bot] commented 2 months ago

Triggered auto assignment to @nkuoch (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] commented 2 months ago

Triggered auto assignment to @alexpensify (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.

github-actions[bot] commented 2 months ago

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.
nkdengineer commented 2 months ago

This comes from https://github.com/Expensify/App/pull/48055

Proposal

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

The expense is not deleted.

What is the root cause of that problem?

For now, we only get the navigate-back URL in deleteTransaction function

https://github.com/Expensify/App/blob/ef6a64c2f5a193babdb2f14a172aea4748502033/src/pages/ReportDetailsPage.tsx#L707-L711

Then here if navigateBackToAfterDelete .current is empty here, we only dismiss the modal without calling the delete expense API. https://github.com/Expensify/App/blob/ef6a64c2f5a193babdb2f14a172aea4748502033/src/pages/ReportDetailsPage.tsx#L813-L815

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

We should move the logic to delete the expense outside the if-else statement above

if (!navigateBackToAfterDelete.current) {
    Navigation.dismissModal();
} else {
    ReportUtils.navigateBackAfterDeleteTransaction(navigateBackToAfterDelete.current, true);
}

setTimeout(() => {
    if (ReportActionsUtils.isTrackExpenseAction(requestParentReportAction)) {
        return;
    };
    IOU.deleteMoneyRequest(iouTransactionID, requestParentReportAction, isSingleTransactionView);
}, CONST.ANIMATED_TRANSITION);

https://github.com/Expensify/App/blob/ef6a64c2f5a193babdb2f14a172aea4748502033/src/pages/ReportDetailsPage.tsx#L820-L824

Or we can also call the delete API here without setTimeout

if (!navigateBackToAfterDelete.current) {
    if (!ReportActionsUtils.isTrackExpenseAction(requestParentReportAction)) {
        IOU.deleteMoneyRequest(iouTransactionID, requestParentReportAction, isSingleTransactionView);
    }
    Navigation.dismissModal();
}

https://github.com/Expensify/App/blob/ef6a64c2f5a193babdb2f14a172aea4748502033/src/pages/ReportDetailsPage.tsx#L813-L815

What alternative solutions did you explore? (Optional)

luacmartins commented 2 months ago

@nkdengineer are you available to work on a fix now?

nkdengineer commented 2 months ago

@luacmartins sure.

luacmartins commented 2 months ago

cc @daledah @alitoshmatov since this is a regression from https://github.com/Expensify/App/pull/48055

luacmartins commented 2 months ago

@nkdengineer all yours

melvin-bot[bot] commented 2 months ago

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

Nodebrute commented 2 months ago

@luacmartins we have another regression from https://github.com/Expensify/App/pull/48055

luacmartins commented 2 months ago

Ok, we have potentially 3 regressions from that PR. I'm just gonna revert it instead of patching multiple things. @nkdengineer please pause working on your PR.

luacmartins commented 2 months ago

This is fixed on staging. Closing.