Skip to content

Commit

Permalink
Merge pull request Expensify#46272 from dominictb/fix/45699-delete-task
Browse files Browse the repository at this point in the history
fix: dismiss modal after deleting task
  • Loading branch information
thienlnam authored Aug 5, 2024
2 parents 13beeac + f401f4f commit aa3804e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ function deleteTask(report: OnyxEntry<OnyxTypes.Report>) {
Report.notifyNewAction(report.reportID, currentUserAccountID);

if (shouldDeleteTaskReport) {
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(parentReport?.reportID ?? '-1'));
return ROUTES.REPORT_WITH_ID.getRoute(parentReport?.reportID ?? '-1');
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
setIsDeleteModalVisible(false);

if (caseID === CASES.DEFAULT) {
Task.deleteTask(report);
navigateBackToAfterDelete.current = undefined;
navigateBackToAfterDelete.current = Task.deleteTask(report);
return;
}

Expand Down Expand Up @@ -784,6 +783,13 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
onModalHide={() => {
// We use isTransactionDeleted to know if the modal hides because the user deletes the transaction.
if (!isTransactionDeleted.current) {
if (caseID === CASES.DEFAULT) {
if (navigateBackToAfterDelete.current) {
Navigation.goBack(navigateBackToAfterDelete.current);
} else {
Navigation.dismissModal();
}
}
return;
}

Expand Down

0 comments on commit aa3804e

Please sign in to comment.