Skip to content

Commit 187c7b3

Browse files
committed
updated to fix parent report return behavior
1 parent b4bd2cf commit 187c7b3

2 files changed

Lines changed: 6 additions & 43 deletions

File tree

src/libs/ReportUtils.ts

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ import {
162162
getReportActionHtml,
163163
getReportActionMessage as getReportActionMessageReportUtils,
164164
getReportActionMessageText,
165-
getReportActions,
166165
getReportActionText,
167166
getRetractedMessage,
168167
getTravelUpdateMessage,
@@ -8808,43 +8807,25 @@ function isMoneyRequestReportPendingDeletion(reportOrID: OnyxEntry<Report> | str
88088807
}
88098808

88108809
function navigateToLinkedReportAction(ancestor: Ancestor, isInNarrowPaneModal: boolean, canUserPerformWrite: boolean | undefined, isOffline: boolean) {
8811-
const parentReport = getReportOrDraftReport(ancestor.report.parentReportID);
8812-
const parentReportAction = getReportAction(ancestor.report.parentReportID, ancestor.report.parentReportActionID);
8813-
8814-
let newAncestor = ancestor;
8815-
// If `parentReport` is an money report with one transaction, navigate directly to `parentReport`,
8816-
// preventing redundant navigation when threading back to the parent chat thread
8817-
if (
8818-
parentReport &&
8819-
parentReportAction &&
8820-
getOneTransactionThreadReportID(parentReport, getReportOrDraftReport(parentReport.chatReportID), getReportActions(parentReport), isOffline, undefined, true)
8821-
) {
8822-
newAncestor = {
8823-
...ancestor,
8824-
report: parentReport,
8825-
reportAction: parentReportAction,
8826-
};
8827-
}
8828-
88298810
if (isInNarrowPaneModal) {
88308811
Navigation.navigate(
88318812
ROUTES.SEARCH_REPORT.getRoute({
8832-
reportID: newAncestor.report.reportID,
8833-
reportActionID: newAncestor.reportAction.reportActionID,
8813+
reportID: ancestor.report.reportID,
8814+
reportActionID: ancestor.reportAction.reportActionID,
88348815
backTo: SCREENS.SEARCH.REPORT_RHP,
88358816
}),
88368817
);
88378818
return;
88388819
}
88398820

88408821
// Pop the thread report screen before navigating to the chat report.
8841-
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(newAncestor.report.reportID));
8822+
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.reportID));
88428823

8843-
const isVisibleAction = shouldReportActionBeVisible(newAncestor.reportAction, newAncestor.reportAction.reportActionID, canUserPerformWrite);
8824+
const isVisibleAction = shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID, canUserPerformWrite);
88448825

88458826
if (isVisibleAction && !isOffline) {
88468827
// Pop the chat report screen before navigating to the linked report action.
8847-
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(newAncestor.report.reportID, newAncestor.reportAction.reportActionID));
8828+
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.reportID, ancestor.reportAction.reportActionID));
88488829
}
88498830
}
88508831

src/pages/home/HeaderView.tsx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import useHasTeam2025Pricing from '@hooks/useHasTeam2025Pricing';
2626
import useLoadingBarVisibility from '@hooks/useLoadingBarVisibility';
2727
import useLocalize from '@hooks/useLocalize';
2828
import useOnyx from '@hooks/useOnyx';
29-
import useNetwork from '@hooks/useNetwork';
3029
import usePolicy from '@hooks/usePolicy';
3130
import useReportIsArchived from '@hooks/useReportIsArchived';
3231
import useResponsiveLayout from '@hooks/useResponsiveLayout';
@@ -37,7 +36,6 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
3736
import Navigation from '@libs/Navigation/Navigation';
3837
import {getPersonalDetailsForAccountIDs} from '@libs/OptionsListUtils';
3938
import Parser from '@libs/Parser';
40-
import {getOneTransactionThreadReportID, getReportActions} from '@libs/ReportActionsUtils';
4139
import {
4240
canJoinChat,
4341
canUserPerformWriteAction,
@@ -50,7 +48,6 @@ import {
5048
getPolicyName,
5149
getReportDescription,
5250
getReportName,
53-
getReportOrDraftReport,
5451
hasReportNameError,
5552
isAdminRoom,
5653
isArchivedReport,
@@ -143,22 +140,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
143140
const isChatRoom = isChatRoomReportUtils(report);
144141
const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report);
145142
const isTaskReport = isTaskReportReportUtils(report);
146-
const [parentOfParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.parentReportID}`, {canBeMissing: true});
147-
const {isOffline} = useNetwork();
148-
const reportHeaderData =
149-
((!isTaskReport && !isChatThread) ||
150-
(parentOfParentReport &&
151-
!!getOneTransactionThreadReportID(
152-
parentOfParentReport,
153-
getReportOrDraftReport(parentOfParentReport?.chatReportID),
154-
getReportActions(parentOfParentReport),
155-
isOffline,
156-
undefined,
157-
true,
158-
))) &&
159-
report?.parentReportID
160-
? parentReport
161-
: report;
143+
const reportHeaderData = !isTaskReport && !isChatThread && report?.parentReportID ? parentReport : report;
162144
// Use sorted display names for the title for group chats on native small screen widths
163145
const title = getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy);
164146
const subtitle = getChatRoomSubtitle(reportHeaderData);

0 commit comments

Comments
 (0)