diff --git a/src/pages/workspace/accounting/AccountingContext.tsx b/src/pages/workspace/accounting/AccountingContext.tsx index 1efeb7d019b9..6250f99b21f2 100644 --- a/src/pages/workspace/accounting/AccountingContext.tsx +++ b/src/pages/workspace/accounting/AccountingContext.tsx @@ -1,6 +1,7 @@ import type {MutableRefObject, RefObject} from 'react'; import React, {useContext, useMemo, useRef, useState} from 'react'; import type {View} from 'react-native'; +import type {OnyxEntry} from 'react-native-onyx'; import AccountingConnectionConfirmationModal from '@components/AccountingConnectionConfirmationModal'; import useLocalize from '@hooks/useLocalize'; import {removePolicyConnection} from '@libs/actions/connections'; @@ -47,14 +48,14 @@ const defaultAccountingContext = { const AccountingContext = React.createContext(defaultAccountingContext); type AccountingContextProviderProps = ChildrenProps & { - policy: Policy; + policy: OnyxEntry; }; function AccountingContextProvider({children, policy}: AccountingContextProviderProps) { const popoverAnchorRefs = useRef>>(defaultAccountingContext.popoverAnchorRefs.current); const [activeIntegration, setActiveIntegration] = useState(); const {translate} = useLocalize(); - const policyID = policy.id; + const policyID = policy?.id ?? '-1'; const startIntegrationFlow = React.useCallback( (newActiveIntegration: ActiveIntegration) => { diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index a8ca3fc2054f..2df5932b9260 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -55,7 +55,7 @@ type RouteParams = { }; function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { - const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy.id}`); + const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`); const theme = useTheme(); const styles = useThemeStyles(); const {translate, datetimeToRelative: getDatetimeToRelative} = useLocalize(); diff --git a/src/pages/workspace/accounting/types.ts b/src/pages/workspace/accounting/types.ts index ed4f11312f2a..4ff7728e5575 100644 --- a/src/pages/workspace/accounting/types.ts +++ b/src/pages/workspace/accounting/types.ts @@ -14,8 +14,7 @@ type PolicyAccountingPageOnyxProps = { type PolicyAccountingPageProps = WithPolicyConnectionsProps & PolicyAccountingPageOnyxProps & { - // This is not using OnyxEntry because the HOC withPolicyConnections will only render this component if there is a policy - policy: Policy; + policy: OnyxEntry; }; type WorkspaceUpgradeNavigationDetails = {