Skip to content

Commit 6a39f9d

Browse files
committed
hide categorize conceirge whisper message when policy category is disabled
1 parent 9e3ecbb commit 6a39f9d

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/libs/ReportActionsUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ function isResolvedConciergeDescriptionOptions(reportAction: OnyxEntry<ReportAct
891891
* Checks if a reportAction is fit for display, meaning that it's not deprecated, is of a valid
892892
* and supported type, it's not deleted and also not closed.
893893
*/
894-
function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key: string | number, canUserPerformWriteAction?: boolean): boolean {
894+
function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key: string | number, canUserPerformWriteAction?: boolean, policy?: OnyxEntry<Policy>): boolean {
895895
if (!reportAction) {
896896
return false;
897897
}
@@ -957,6 +957,10 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key:
957957
return false;
958958
}
959959

960+
if (isConciergeCategoryOptions(reportAction) && policy && !policy.areCategoriesEnabled) {
961+
return false;
962+
}
963+
960964
// All other actions are displayed except thread parents, deleted, or non-pending actions
961965
const isDeleted = isDeletedAction(reportAction);
962966
const isPending = !!reportAction.pendingAction;

src/pages/home/report/ReportActionsView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ function ReportActionsView({
108108
const reportPreviewAction = useMemo(() => getReportPreviewAction(report.chatReportID, report.reportID), [report.chatReportID, report.reportID]);
109109
const didLayout = useRef(false);
110110
const {isOffline} = useNetwork();
111+
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, {canBeMissing: true});
111112

112113
const {shouldUseNarrowLayout} = useResponsiveLayout();
113114
const isFocused = useIsFocused();
@@ -222,10 +223,10 @@ function ReportActionsView({
222223
reportActions.filter(
223224
(reportAction) =>
224225
(isOffline || isDeletedParentAction(reportAction) || reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || reportAction.errors) &&
225-
shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canPerformWriteAction) &&
226+
shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canPerformWriteAction, policy) &&
226227
isIOUActionMatchingTransactionList(reportAction, reportTransactionIDs),
227228
),
228-
[reportActions, isOffline, canPerformWriteAction, reportTransactionIDs],
229+
[reportActions, isOffline, canPerformWriteAction, policy, reportTransactionIDs],
229230
);
230231

231232
const newestReportAction = useMemo(() => reportActions?.at(0), [reportActions]);

0 commit comments

Comments
 (0)