diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 35235ca23893..466566eece77 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -8807,25 +8807,11 @@ function isMoneyRequestReportPendingDeletion(reportOrID: OnyxEntry | str } function navigateToLinkedReportAction(ancestor: Ancestor, isInNarrowPaneModal: boolean, canUserPerformWrite: boolean | undefined, isOffline: boolean) { - const parentReport = getReportOrDraftReport(ancestor.report.parentReportID); - const parentReportAction = getReportAction(ancestor.report.parentReportID, ancestor.report.parentReportActionID); - - let newAncestor = ancestor; - // If `parentReport` is an IOU or Expense report, navigate directly to `parentReport`, - // preventing redundant navigation when threading back to the parent chat thread - if (parentReport && parentReportAction && (isIOUReport(parentReport) || isExpenseReport(parentReport))) { - newAncestor = { - ...ancestor, - report: parentReport, - reportAction: parentReportAction, - }; - } - if (isInNarrowPaneModal) { Navigation.navigate( ROUTES.SEARCH_REPORT.getRoute({ - reportID: newAncestor.report.reportID, - reportActionID: newAncestor.reportAction.reportActionID, + reportID: ancestor.report.reportID, + reportActionID: ancestor.reportAction.reportActionID, backTo: SCREENS.SEARCH.REPORT_RHP, }), ); @@ -8833,13 +8819,13 @@ function navigateToLinkedReportAction(ancestor: Ancestor, isInNarrowPaneModal: b } // Pop the thread report screen before navigating to the chat report. - Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(newAncestor.report.reportID)); + Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.reportID)); - const isVisibleAction = shouldReportActionBeVisible(newAncestor.reportAction, newAncestor.reportAction.reportActionID, canUserPerformWrite); + const isVisibleAction = shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID, canUserPerformWrite); if (isVisibleAction && !isOffline) { // Pop the chat report screen before navigating to the linked report action. - Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(newAncestor.report.reportID, newAncestor.reportAction.reportActionID)); + Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.reportID, ancestor.reportAction.reportActionID)); } } diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index ec89a7a9b813..d6779d8153dc 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -56,11 +56,9 @@ import { isChatUsedForOnboarding as isChatUsedForOnboardingReportUtils, isCurrentUserSubmitter, isDeprecatedGroupDM, - isExpenseReport, isExpenseRequest, isGroupChat as isGroupChatReportUtils, isInvoiceRoom, - isIOUReport, isOpenTaskReport, isPolicyExpenseChat as isPolicyExpenseChatReportUtils, isSelfDM as isSelfDMReportUtils, @@ -142,11 +140,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked, const isChatRoom = isChatRoomReportUtils(report); const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report); const isTaskReport = isTaskReportReportUtils(report); - const [parentOfParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.parentReportID}`, {canBeMissing: true}); - const reportHeaderData = - ((!isTaskReport && !isChatThread) || (parentOfParentReport && (isIOUReport(parentOfParentReport) || isExpenseReport(parentOfParentReport)))) && report?.parentReportID - ? parentReport - : report; + const reportHeaderData = !isTaskReport && !isChatThread && report?.parentReportID ? parentReport : report; // Use sorted display names for the title for group chats on native small screen widths const title = getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy); const subtitle = getChatRoomSubtitle(reportHeaderData);