Skip to content

Commit

Permalink
FIX: Task delete confirmation Cancel button navigates to parent report
Browse files Browse the repository at this point in the history
  • Loading branch information
ikevin127 committed Jan 9, 2025
1 parent f294b37 commit 2376407
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -875,22 +875,15 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta

// Where to navigate back to after deleting the transaction and its report.
const navigateToTargetUrl = useCallback(() => {
let urlToNavigateBack: string | undefined;

// If transaction was not deleted (i.e. Cancel was clicked), do nothing
// which only dismiss the delete confirmation modal
if (!isTransactionDeleted.current) {
if (caseID === CASES.DEFAULT) {
urlToNavigateBack = Task.getNavigationUrlOnTaskDelete(report);
if (urlToNavigateBack) {
Report.setDeleteTransactionNavigateBackUrl(urlToNavigateBack);
Navigation.goBack(urlToNavigateBack as Route);
} else {
Navigation.dismissModal();
}
return;
}
return;
}

let urlToNavigateBack: string | undefined;

// Only proceed with navigation logic if transaction was actually deleted
if (!isEmptyObject(requestParentReportAction)) {
const isTrackExpense = ReportActionsUtils.isTrackExpenseAction(requestParentReportAction);
if (isTrackExpense) {
Expand All @@ -906,7 +899,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
Report.setDeleteTransactionNavigateBackUrl(urlToNavigateBack);
ReportUtils.navigateBackOnDeleteTransaction(urlToNavigateBack as Route, true);
}
}, [caseID, iouTransactionID, moneyRequestReport?.reportID, report, requestParentReportAction, isSingleTransactionView, isTransactionDeleted]);
}, [report, iouTransactionID, requestParentReportAction, isSingleTransactionView, isTransactionDeleted, moneyRequestReport?.reportID]);

Check warning on line 902 in src/pages/ReportDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has an unnecessary dependency: 'report'. Either exclude it or remove the dependency array

const mentionReportContextValue = useMemo(() => ({currentReportID: report.reportID, exactlyMatch: true}), [report.reportID]);

Expand Down

0 comments on commit 2376407

Please sign in to comment.