diff --git a/src/pages/home/report/SystemChatReportFooterMessage.tsx b/src/pages/home/report/SystemChatReportFooterMessage.tsx index 6e5688282b47..a946968f0ec7 100644 --- a/src/pages/home/report/SystemChatReportFooterMessage.tsx +++ b/src/pages/home/report/SystemChatReportFooterMessage.tsx @@ -1,6 +1,6 @@ import React, {useMemo} from 'react'; import {withOnyx} from 'react-native-onyx'; -import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; import Banner from '@components/Banner'; import * as Expensicons from '@components/Icon/Expensicons'; import Text from '@components/Text'; @@ -8,37 +8,32 @@ import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as PolicyUtils from '@libs/PolicyUtils'; +import * as ReportUtils from '@libs/ReportUtils'; import Navigation from '@navigation/Navigation'; import * as ReportInstance from '@userActions/Report'; import type {OnboardingPurposeType} from '@src/CONST'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {Policy as PolicyType, Report} from '@src/types/onyx'; type SystemChatReportFooterMessageOnyxProps = { /** Saved onboarding purpose selected by the user */ choice: OnyxEntry; - /** Collection of reports */ - reports: OnyxCollection; - - /** The list of this user's policies */ - policies: OnyxCollection; + /** policyID for main workspace */ + activePolicyID: OnyxEntry>; }; type SystemChatReportFooterMessageProps = SystemChatReportFooterMessageOnyxProps; -function SystemChatReportFooterMessage({choice, reports, policies}: SystemChatReportFooterMessageProps) { +function SystemChatReportFooterMessage({choice, activePolicyID}: SystemChatReportFooterMessageProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const adminChatReport = useMemo(() => { - const adminsReports = Object.values(reports ?? {}).filter((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ADMINS); - const activePolicies = Object.values(policies ?? {}).filter((policy) => PolicyUtils.shouldShowPolicy(policy, false)); - - return adminsReports.find((report) => activePolicies.find((policy) => policy?.id === report?.policyID)); - }, [policies, reports]); + const policy = PolicyUtils.getPolicy(activePolicyID ?? ''); + return ReportUtils.getReport(String(policy.chatReportIDAdmins)); + }, [activePolicyID]); const content = useMemo(() => { switch (choice) { @@ -79,10 +74,9 @@ export default withOnyx