Skip to content

Commit

Permalink
Merge pull request #48390 from daledah/fix/47946
Browse files Browse the repository at this point in the history
fix: app crash when clicking on not found policy
  • Loading branch information
youssef-lr authored Sep 10, 2024
2 parents 5131bc5 + bbbf915 commit 7689839
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/pages/workspace/accounting/AccountingContext.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -47,14 +48,14 @@ const defaultAccountingContext = {
const AccountingContext = React.createContext<AccountingContextType>(defaultAccountingContext);

type AccountingContextProviderProps = ChildrenProps & {
policy: Policy;
policy: OnyxEntry<Policy>;
};

function AccountingContextProvider({children, policy}: AccountingContextProviderProps) {
const popoverAnchorRefs = useRef<Record<string, MutableRefObject<View | null>>>(defaultAccountingContext.popoverAnchorRefs.current);
const [activeIntegration, setActiveIntegration] = useState<ActiveIntegrationState>();
const {translate} = useLocalize();
const policyID = policy.id;
const policyID = policy?.id ?? '-1';

const startIntegrationFlow = React.useCallback(
(newActiveIntegration: ActiveIntegration) => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/pages/workspace/accounting/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ type PolicyAccountingPageOnyxProps = {

type PolicyAccountingPageProps = WithPolicyConnectionsProps &
PolicyAccountingPageOnyxProps & {
// This is not using OnyxEntry<OnyxTypes.Policy> because the HOC withPolicyConnections will only render this component if there is a policy
policy: Policy;
policy: OnyxEntry<Policy>;
};

type WorkspaceUpgradeNavigationDetails = {
Expand Down

0 comments on commit 7689839

Please sign in to comment.