Skip to content

Commit

Permalink
Merge pull request #40368 from rayane-djouah/Update-thread-headers-an…
Browse files Browse the repository at this point in the history
…cestry-to-deep-link-back-to-the-original-comment

[CP Staging] Fix: Workspace - Deleting a message on Announce room takes user to another report page

(cherry picked from commit a106481)
  • Loading branch information
roryabraham authored and OSBotify committed Apr 18, 2024
1 parent d773502 commit dec88fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,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);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -274,9 +272,6 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
}
} else if (reportAction) {
Report.deleteReportComment(reportIDRef.current, reportAction);
if (!((reportAction?.childVisibleActionCount ?? 0) > 0)) {
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(reportIDRef.current));
}
}

DeviceEventEmitter.emit(`deletedReportAction_${reportIDRef.current}`, reportAction?.reportActionID);
Expand Down

0 comments on commit dec88fb

Please sign in to comment.