diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 41079d20a982..7bcb82861769 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1277,6 +1277,12 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) { CachedPDFPaths.clearByKey(reportActionID); API.write(WRITE_COMMANDS.DELETE_COMMENT, parameters, {optimisticData, successData, failureData}); + + // if we are linking to the report action, and we are deleting it, and it's not a deleted parent action, + // we should navigate to its report in order to not show not found page + if (Navigation.isActiveRoute(ROUTES.REPORT_WITH_ID.getRoute(reportID, reportActionID)) && !isDeletedParentAction) { + Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(reportID), true); + } } /** diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx index 6c9ed8b0a008..6cb688ff2558 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx @@ -9,11 +9,9 @@ import ConfirmModal from '@components/ConfirmModal'; import PopoverWithMeasuredContent from '@components/PopoverWithMeasuredContent'; import useLocalize from '@hooks/useLocalize'; import calculateAnchorPosition from '@libs/calculateAnchorPosition'; -import Navigation from '@libs/Navigation/Navigation'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as IOU from '@userActions/IOU'; import * as Report from '@userActions/Report'; -import ROUTES from '@src/ROUTES'; import type {AnchorDimensions} from '@src/styles'; import type {ReportAction} from '@src/types/onyx'; import BaseReportActionContextMenu from './BaseReportActionContextMenu'; @@ -274,9 +272,6 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef 0)) { - Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(reportIDRef.current)); - } } DeviceEventEmitter.emit(`deletedReportAction_${reportIDRef.current}`, reportAction?.reportActionID);