Skip to content

Commit db267d0

Browse files
authored
Merge pull request Expensify#64400 from dmkt9/fix/64351
Fix - Header link takes 2 steps back to expense report when reply is created in transaction thread
2 parents 38f7822 + 187c7b3 commit db267d0

2 files changed

Lines changed: 6 additions & 26 deletions

File tree

src/libs/ReportUtils.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8818,39 +8818,25 @@ function isMoneyRequestReportPendingDeletion(reportOrID: OnyxEntry<Report> | str
88188818
}
88198819

88208820
function navigateToLinkedReportAction(ancestor: Ancestor, isInNarrowPaneModal: boolean, canUserPerformWrite: boolean | undefined, isOffline: boolean) {
8821-
const parentReport = getReportOrDraftReport(ancestor.report.parentReportID);
8822-
const parentReportAction = getReportAction(ancestor.report.parentReportID, ancestor.report.parentReportActionID);
8823-
8824-
let newAncestor = ancestor;
8825-
// If `parentReport` is an IOU or Expense report, navigate directly to `parentReport`,
8826-
// preventing redundant navigation when threading back to the parent chat thread
8827-
if (parentReport && parentReportAction && (isIOUReport(parentReport) || isExpenseReport(parentReport))) {
8828-
newAncestor = {
8829-
...ancestor,
8830-
report: parentReport,
8831-
reportAction: parentReportAction,
8832-
};
8833-
}
8834-
88358821
if (isInNarrowPaneModal) {
88368822
Navigation.navigate(
88378823
ROUTES.SEARCH_REPORT.getRoute({
8838-
reportID: newAncestor.report.reportID,
8839-
reportActionID: newAncestor.reportAction.reportActionID,
8824+
reportID: ancestor.report.reportID,
8825+
reportActionID: ancestor.reportAction.reportActionID,
88408826
backTo: SCREENS.SEARCH.REPORT_RHP,
88418827
}),
88428828
);
88438829
return;
88448830
}
88458831

88468832
// Pop the thread report screen before navigating to the chat report.
8847-
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(newAncestor.report.reportID));
8833+
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.reportID));
88488834

8849-
const isVisibleAction = shouldReportActionBeVisible(newAncestor.reportAction, newAncestor.reportAction.reportActionID, canUserPerformWrite);
8835+
const isVisibleAction = shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID, canUserPerformWrite);
88508836

88518837
if (isVisibleAction && !isOffline) {
88528838
// Pop the chat report screen before navigating to the linked report action.
8853-
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(newAncestor.report.reportID, newAncestor.reportAction.reportActionID));
8839+
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.reportID, ancestor.reportAction.reportActionID));
88548840
}
88558841
}
88568842

src/pages/home/HeaderView.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@ import {
5656
isChatUsedForOnboarding as isChatUsedForOnboardingReportUtils,
5757
isCurrentUserSubmitter,
5858
isDeprecatedGroupDM,
59-
isExpenseReport,
6059
isExpenseRequest,
6160
isGroupChat as isGroupChatReportUtils,
6261
isInvoiceRoom,
63-
isIOUReport,
6462
isOpenTaskReport,
6563
isPolicyExpenseChat as isPolicyExpenseChatReportUtils,
6664
isSelfDM as isSelfDMReportUtils,
@@ -142,11 +140,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
142140
const isChatRoom = isChatRoomReportUtils(report);
143141
const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report);
144142
const isTaskReport = isTaskReportReportUtils(report);
145-
const [parentOfParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.parentReportID}`, {canBeMissing: true});
146-
const reportHeaderData =
147-
((!isTaskReport && !isChatThread) || (parentOfParentReport && (isIOUReport(parentOfParentReport) || isExpenseReport(parentOfParentReport)))) && report?.parentReportID
148-
? parentReport
149-
: report;
143+
const reportHeaderData = !isTaskReport && !isChatThread && report?.parentReportID ? parentReport : report;
150144
// Use sorted display names for the title for group chats on native small screen widths
151145
const title = getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy);
152146
const subtitle = getChatRoomSubtitle(reportHeaderData);

0 commit comments

Comments
 (0)