Skip to content

Commit 54aae53

Browse files
committed
Pass the report action for reverse checking deleted status
1 parent 2e1b218 commit 54aae53

2 files changed

Lines changed: 35 additions & 7 deletions

File tree

src/libs/ReportActionsUtils.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,14 +1078,36 @@ const supportedActionTypes = new Set<ReportActionName>([...Object.values(otherAc
10781078
* Checks whether an action is actionable track expense and resolved.
10791079
*
10801080
*/
1081-
function isResolvedActionableWhisper(reportAction: OnyxEntry<ReportAction>): boolean {
1081+
function isResolvedActionableWhisper(reportAction: OnyxEntry<ReportAction>, allActionsForReport?: OnyxEntry<ReportActions>): boolean {
10821082
const originalMessage = getOriginalMessage(reportAction);
10831083
if (!originalMessage || typeof originalMessage !== 'object') {
10841084
return false;
10851085
}
10861086
const resolution = 'resolution' in originalMessage ? originalMessage?.resolution : null;
1087+
if (resolution) {
1088+
return true;
1089+
}
1090+
10871091
const deleted = 'deleted' in originalMessage ? originalMessage?.deleted : null;
1088-
return !!resolution || !!deleted;
1092+
if (!deleted) {
1093+
return false;
1094+
}
1095+
1096+
// For mention whispers, only treat as deleted if the parent comment is also deleted.
1097+
// This distinguishes cascade deletion (parent deleted -> whisper should hide) from
1098+
// 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)) {
1101+
const parentOffset = isActionableReportMentionWhisper(reportAction) ? 2n : 1n;
1102+
const parentActionID = String(BigInt(reportAction.reportActionID) - parentOffset);
1103+
const parentAction = allActionsForReport[parentActionID];
1104+
if (parentAction && !isDeletedAction(parentAction)) {
1105+
return false;
1106+
}
1107+
}
1108+
}
1109+
1110+
return true;
10891111
}
10901112

10911113
/**
@@ -1110,7 +1132,13 @@ function isResolvedConciergeDescriptionOptions(reportAction: OnyxEntry<ReportAct
11101132
* Checks if a reportAction is fit for display, meaning that it's not deprecated, is of a valid
11111133
* and supported type, it's not deleted and also not closed.
11121134
*/
1113-
function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key: string | number, canUserPerformWriteAction?: boolean, reportsParam?: OnyxCollection<Report>): boolean {
1135+
function shouldReportActionBeVisible(
1136+
reportAction: OnyxEntry<ReportAction>,
1137+
key: string | number,
1138+
canUserPerformWriteAction?: boolean,
1139+
reportsParam?: OnyxCollection<Report>,
1140+
allActionsForReport?: OnyxEntry<ReportActions>,
1141+
): boolean {
11141142
if (!reportAction) {
11151143
return false;
11161144
}
@@ -1187,7 +1215,7 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key:
11871215
}
11881216

11891217
// If action is actionable whisper and resolved by user, then we don't want to render anything
1190-
if (isActionableWhisper(reportAction) && isResolvedActionableWhisper(reportAction)) {
1218+
if (isActionableWhisper(reportAction) && isResolvedActionableWhisper(reportAction, allActionsForReport)) {
11911219
return false;
11921220
}
11931221

src/libs/actions/OnyxDerived/configs/visibleReportActions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default createOnyxDerivedValueConfig({
7171
if (shouldSkipCachingAction(action)) {
7272
continue;
7373
}
74-
reportVisibility[action.reportActionID] = shouldReportActionBeVisible(action, actionID, undefined, allReports);
74+
reportVisibility[action.reportActionID] = shouldReportActionBeVisible(action, actionID, undefined, allReports, reportActions);
7575
}
7676
}
7777
}
@@ -108,7 +108,7 @@ export default createOnyxDerivedValueConfig({
108108
delete reportVisibility[action.reportActionID];
109109
continue;
110110
}
111-
reportVisibility[action.reportActionID] = shouldReportActionBeVisible(action, actionID, undefined, allReports);
111+
reportVisibility[action.reportActionID] = shouldReportActionBeVisible(action, actionID, undefined, allReports, reportActions);
112112
}
113113
}
114114
}
@@ -158,7 +158,7 @@ export default createOnyxDerivedValueConfig({
158158
continue;
159159
}
160160

161-
reportVisibility[action.reportActionID] = shouldReportActionBeVisible(action, actionID, undefined, allReports);
161+
reportVisibility[action.reportActionID] = shouldReportActionBeVisible(action, actionID, undefined, allReports, reportActions);
162162
}
163163
}
164164

0 commit comments

Comments
 (0)