Skip to content

Commit cc92c84

Browse files
committed
update for filter visible report actions
1 parent 6025f36 commit cc92c84

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

src/libs/ReportUtils.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8634,12 +8634,18 @@ function navigateToLinkedReportAction(ancestor: Ancestor, isInNarrowPaneModal: b
86348634
let newAncestor = ancestor;
86358635
// If `parentReport` is an money report with one transaction, navigate directly to `parentReport`,
86368636
// preventing redundant navigation when threading back to the parent chat thread
8637-
if (parentReport && parentReportAction && !!getOneTransactionThreadReportID(parentReport, getReportOrDraftReport(parentReport.chatReportID), getReportActions(parentReport))) {
8638-
newAncestor = {
8639-
...ancestor,
8640-
report: parentReport,
8641-
reportAction: parentReportAction,
8642-
};
8637+
if (parentReport && parentReportAction) {
8638+
const allParentReportActions = getReportActions(parentReport);
8639+
const visibleParentReportActions = Object.values(allParentReportActions ?? {}).filter(
8640+
(action) => !isMessageDeleted(action) || (action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isOffline),
8641+
);
8642+
if (getOneTransactionThreadReportID(parentReport, getReportOrDraftReport(parentReport.chatReportID), visibleParentReportActions)) {
8643+
newAncestor = {
8644+
...ancestor,
8645+
report: parentReport,
8646+
reportAction: parentReportAction,
8647+
};
8648+
}
86438649
}
86448650

86458651
if (isInNarrowPaneModal) {

src/pages/home/HeaderView.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Text from '@components/Text';
2525
import Tooltip from '@components/Tooltip';
2626
import useHasTeam2025Pricing from '@hooks/useHasTeam2025Pricing';
2727
import useLocalize from '@hooks/useLocalize';
28+
import useNetwork from '@hooks/useNetwork';
2829
import usePolicy from '@hooks/usePolicy';
2930
import useResponsiveLayout from '@hooks/useResponsiveLayout';
3031
import useSubscriptionPlan from '@hooks/useSubscriptionPlan';
@@ -34,7 +35,7 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
3435
import Navigation from '@libs/Navigation/Navigation';
3536
import {getPersonalDetailsForAccountIDs} from '@libs/OptionsListUtils';
3637
import Parser from '@libs/Parser';
37-
import {getOneTransactionThreadReportID, getReportActions} from '@libs/ReportActionsUtils';
38+
import {getOneTransactionThreadReportID, getReportActions, isMessageDeleted} from '@libs/ReportActionsUtils';
3839
import {
3940
canJoinChat,
4041
canUserPerformWriteAction,
@@ -139,10 +140,19 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
139140
const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report);
140141
const isTaskReport = isTaskReportReportUtils(report);
141142
const [parentOfParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.parentReportID}`, {canBeMissing: true});
143+
const {isOffline} = useNetwork();
144+
const visibleParentOfParentReportActions = useMemo(() => {
145+
if (!parentOfParentReport) {
146+
return;
147+
}
148+
149+
const allReportActions = getReportActions(parentOfParentReport);
150+
return Object.values(allReportActions ?? {}).filter((action) => !isMessageDeleted(action) || (action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isOffline));
151+
}, [parentOfParentReport, isOffline]);
142152
const reportHeaderData =
143153
((!isTaskReport && !isChatThread) ||
144154
(parentOfParentReport &&
145-
!!getOneTransactionThreadReportID(parentOfParentReport, getReportOrDraftReport(parentOfParentReport?.chatReportID), getReportActions(parentOfParentReport)))) &&
155+
!!getOneTransactionThreadReportID(parentOfParentReport, getReportOrDraftReport(parentOfParentReport?.chatReportID), visibleParentOfParentReportActions))) &&
146156
report?.parentReportID
147157
? parentReport
148158
: report;

0 commit comments

Comments
 (0)