Skip to content

Commit 6025f36

Browse files
committed
Fix - Header link takes 2 steps back to expense report when reply is created in transaction thread
1 parent 0686278 commit 6025f36

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/libs/ReportUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ import {
154154
getReportActionHtml,
155155
getReportActionMessage as getReportActionMessageReportUtils,
156156
getReportActionMessageText,
157+
getReportActions,
157158
getReportActionText,
158159
getRetractedMessage,
159160
getTravelUpdateMessage,
@@ -8631,9 +8632,9 @@ function navigateToLinkedReportAction(ancestor: Ancestor, isInNarrowPaneModal: b
86318632
const parentReportAction = getReportAction(ancestor.report.parentReportID, ancestor.report.parentReportActionID);
86328633

86338634
let newAncestor = ancestor;
8634-
// If `parentReport` is an IOU or Expense report, navigate directly to `parentReport`,
8635+
// If `parentReport` is an money report with one transaction, navigate directly to `parentReport`,
86358636
// preventing redundant navigation when threading back to the parent chat thread
8636-
if (parentReport && parentReportAction && (isIOUReport(parentReport) || isExpenseReport(parentReport))) {
8637+
if (parentReport && parentReportAction && !!getOneTransactionThreadReportID(parentReport, getReportOrDraftReport(parentReport.chatReportID), getReportActions(parentReport))) {
86378638
newAncestor = {
86388639
...ancestor,
86398640
report: parentReport,
@@ -11252,6 +11253,7 @@ export {
1125211253
hasReportBeenReopened,
1125311254
getMoneyReportPreviewName,
1125411255
getNextApproverAccountID,
11256+
isOneTransactionReport,
1125511257
};
1125611258

1125711259
export type {

src/pages/home/HeaderView.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
3434
import Navigation from '@libs/Navigation/Navigation';
3535
import {getPersonalDetailsForAccountIDs} from '@libs/OptionsListUtils';
3636
import Parser from '@libs/Parser';
37+
import {getOneTransactionThreadReportID, getReportActions} from '@libs/ReportActionsUtils';
3738
import {
3839
canJoinChat,
3940
canUserPerformWriteAction,
@@ -46,6 +47,7 @@ import {
4647
getPolicyName,
4748
getReportDescription,
4849
getReportName,
50+
getReportOrDraftReport,
4951
hasReportNameError,
5052
isAdminRoom,
5153
isArchivedReport,
@@ -54,10 +56,8 @@ import {
5456
isChatUsedForOnboarding as isChatUsedForOnboardingReportUtils,
5557
isCurrentUserSubmitter,
5658
isDeprecatedGroupDM,
57-
isExpenseReport,
5859
isExpenseRequest,
5960
isGroupChat as isGroupChatReportUtils,
60-
isIOUReport,
6161
isOpenTaskReport,
6262
isPolicyExpenseChat as isPolicyExpenseChatReportUtils,
6363
isSelfDM as isSelfDMReportUtils,
@@ -140,7 +140,10 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
140140
const isTaskReport = isTaskReportReportUtils(report);
141141
const [parentOfParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.parentReportID}`, {canBeMissing: true});
142142
const reportHeaderData =
143-
((!isTaskReport && !isChatThread) || (parentOfParentReport && (isIOUReport(parentOfParentReport) || isExpenseReport(parentOfParentReport)))) && report?.parentReportID
143+
((!isTaskReport && !isChatThread) ||
144+
(parentOfParentReport &&
145+
!!getOneTransactionThreadReportID(parentOfParentReport, getReportOrDraftReport(parentOfParentReport?.chatReportID), getReportActions(parentOfParentReport)))) &&
146+
report?.parentReportID
144147
? parentReport
145148
: report;
146149
// Use sorted display names for the title for group chats on native small screen widths

0 commit comments

Comments
 (0)