diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index bfc9c958ed86..24f3391b250f 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -877,7 +877,7 @@ function isResolvedConciergeDescriptionOptions(reportAction: OnyxEntry, key: string | number, canUserPerformWriteAction?: boolean): boolean { +function shouldReportActionBeVisible(reportAction: OnyxEntry, key: string | number, canUserPerformWriteAction?: boolean, policy?: OnyxEntry): boolean { if (!reportAction) { return false; } @@ -936,6 +936,10 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry, key: return false; } + if (isConciergeCategoryOptions(reportAction) && policy && !policy.areCategoriesEnabled) { + return false; + } + // All other actions are displayed except thread parents, deleted, or non-pending actions const isDeleted = isDeletedAction(reportAction); const isPending = !!reportAction.pendingAction; diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index cb823521bfcd..4c32d819db11 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -108,6 +108,7 @@ function ReportActionsView({ const reportPreviewAction = useMemo(() => getReportPreviewAction(report.chatReportID, report.reportID), [report.chatReportID, report.reportID]); const didLayout = useRef(false); const {isOffline} = useNetwork(); + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, {canBeMissing: true}); const {shouldUseNarrowLayout} = useResponsiveLayout(); const isFocused = useIsFocused(); @@ -222,10 +223,10 @@ function ReportActionsView({ reportActions.filter( (reportAction) => (isOffline || isDeletedParentAction(reportAction) || reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || reportAction.errors) && - shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canPerformWriteAction) && + shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canPerformWriteAction, policy) && isIOUActionMatchingTransactionList(reportAction, reportTransactionIDs), ), - [reportActions, isOffline, canPerformWriteAction, reportTransactionIDs], + [reportActions, isOffline, canPerformWriteAction, reportTransactionIDs, policy], ); const newestReportAction = useMemo(() => reportActions?.at(0), [reportActions]); diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 14e476617b78..6673dceb6242 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -10,6 +10,7 @@ import * as ReportActionsUtils from '../../src/libs/ReportActionsUtils'; import {getCardIssuedMessage, getOneTransactionThreadReportID, getOriginalMessage, getSendMoneyFlowAction, isIOUActionMatchingTransactionList} from '../../src/libs/ReportActionsUtils'; import ONYXKEYS from '../../src/ONYXKEYS'; import type {Card, OriginalMessageIOU, Report, ReportAction} from '../../src/types/onyx'; +import createRandomPolicy from '../utils/collections/policies'; import createRandomReportAction from '../utils/collections/reportActions'; import {createRandomReport} from '../utils/collections/reports'; import * as LHNTestUtils from '../utils/LHNTestUtils'; @@ -1411,6 +1412,14 @@ describe('ReportActionsUtils', () => { const actual = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true); expect(actual).toBe(true); }); + + it("should return false for concierge categorize suggestion whisper message when the policy's category feature is disabled", () => { + const reportAction: ReportAction = {...createRandomReportAction(123), actionName: CONST.REPORT.ACTIONS.TYPE.CONCIERGE_CATEGORY_OPTIONS}; + const categoryFeatureDisabledPolicy = {...createRandomPolicy(1234), areCategoriesEnabled: false}; + + const result = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true, categoryFeatureDisabledPolicy); + expect(result).toBe(false); + }); }); describe('getPolicyChangeLogUpdateEmployee', () => {