From b7565932c1ed3d64ec6ba871b81b1d7d8faf7885 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Wed, 17 Apr 2024 19:34:28 +0100 Subject: [PATCH 1/2] Fix: Workspace - Deleting a message on Announce room takes user to another report page --- src/libs/actions/Report.ts | 6 ++++++ .../report/ContextMenu/PopoverReportActionContextMenu.tsx | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 41079d20a982..5922da9dc181 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 we are deleting 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); From f34d1f49cb23f2a8d2c2117232e692e490296bab Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Wed, 17 Apr 2024 19:54:42 +0100 Subject: [PATCH 2/2] Correct comment --- src/libs/actions/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 5922da9dc181..7bcb82861769 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1278,7 +1278,7 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) { API.write(WRITE_COMMANDS.DELETE_COMMENT, parameters, {optimisticData, successData, failureData}); - // if we are linking to the report action we are deleting and it's not a deleted parent action, + // 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);