Skip to content

Commit fb54737

Browse files
committed
Pass all report actions to shouldReportActionBeVisible
1 parent f7600a5 commit fb54737

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/libs/ReportActionsUtils.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,11 +1096,13 @@ function isResolvedActionableWhisper(reportAction: OnyxEntry<ReportAction>, allA
10961096
// For mention whispers, only treat as deleted if the parent comment is also deleted.
10971097
// This distinguishes cascade deletion (parent deleted -> whisper should hide) from
10981098
// the backend's one-per-user cleanup (parent still exists -> whisper should stay visible).
1099-
if (allActionsForReport && reportAction?.reportActionID) {
1100-
if (isActionableMentionWhisper(reportAction) || isActionableReportMentionWhisper(reportAction)) {
1099+
if (reportAction?.reportActionID && (isActionableMentionWhisper(reportAction) || isActionableReportMentionWhisper(reportAction))) {
1100+
const reportID = reportAction.reportID;
1101+
const actions = allActionsForReport ?? (reportID ? allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] : undefined);
1102+
if (actions) {
11011103
const parentOffset = isActionableReportMentionWhisper(reportAction) ? 2n : 1n;
11021104
const parentActionID = String(BigInt(reportAction.reportActionID) - parentOffset);
1103-
const parentAction = allActionsForReport[parentActionID];
1105+
const parentAction = actions[parentActionID];
11041106
if (parentAction && !isDeletedAction(parentAction)) {
11051107
return false;
11061108
}
@@ -1251,22 +1253,27 @@ function isReportActionVisible(
12511253
return false;
12521254
}
12531255

1256+
// Look up all actions for this report so the parent-check in isResolvedActionableWhisper
1257+
// can determine whether a whisper's `deleted` flag reflects a real cascade deletion
1258+
// (parent comment deleted) vs. the backend's one-per-user cleanup (parent still exists).
1259+
const reportActionsForReport = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`];
1260+
12541261
// Actions with pendingAction are optimistic or in-flight, so their visibility may differ
12551262
// from what's cached in visibleReportActions (which reflects persisted Onyx data).
12561263
// We must recalculate visibility at runtime to ensure accuracy for these transient states.
12571264
if (reportAction.pendingAction) {
1258-
return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction);
1265+
return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction, undefined, reportActionsForReport);
12591266
}
12601267

12611268
if (visibleReportActions) {
12621269
const reportCache = visibleReportActions[reportID];
12631270
if (!reportCache) {
1264-
return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction);
1271+
return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction, undefined, reportActionsForReport);
12651272
}
12661273
const staticVisibility = reportCache[reportAction.reportActionID];
12671274
// If action is not in derived value cache, fall back to runtime calculation
12681275
if (staticVisibility === undefined) {
1269-
return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction);
1276+
return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction, undefined, reportActionsForReport);
12701277
}
12711278
if (!staticVisibility) {
12721279
return false;
@@ -1276,7 +1283,7 @@ function isReportActionVisible(
12761283
}
12771284
return true;
12781285
}
1279-
return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction);
1286+
return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction, undefined, reportActionsForReport);
12801287
}
12811288

12821289
/**

0 commit comments

Comments
 (0)