From 4148ccbe07f7f1f8b26caa4aa80cd4785cbd7955 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 12 Aug 2025 14:41:52 +0700 Subject: [PATCH 1/3] fix: not here page appears briefly when user switches account --- src/hooks/useSubscriptionPlan.ts | 4 ++-- src/libs/actions/Delegate.ts | 1 - src/pages/settings/Subscription/SubscriptionSettingsPage.tsx | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hooks/useSubscriptionPlan.ts b/src/hooks/useSubscriptionPlan.ts index f0221b566bfe..3f5d55487192 100644 --- a/src/hooks/useSubscriptionPlan.ts +++ b/src/hooks/useSubscriptionPlan.ts @@ -7,10 +7,10 @@ import useOnyx from './useOnyx'; function useSubscriptionPlan() { const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); - const [session] = useOnyx(ONYXKEYS.SESSION); + const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA); // Filter workspaces in which user is the owner and the type is either corporate (control) or team (collect) - const ownerPolicies = useMemo(() => getOwnedPaidPolicies(policies, session?.accountID ?? -1), [policies, session?.accountID]); + const ownerPolicies = useMemo(() => getOwnedPaidPolicies(policies, userMetadata?.accountID ?? -1), [policies, userMetadata?.accountID]); if (isEmptyObject(ownerPolicies)) { return null; diff --git a/src/libs/actions/Delegate.ts b/src/libs/actions/Delegate.ts index f60b5b1dfd88..7177ceb26de1 100644 --- a/src/libs/actions/Delegate.ts +++ b/src/libs/actions/Delegate.ts @@ -67,7 +67,6 @@ const KEYS_TO_PRESERVE_DELEGATE_ACCESS = [ ONYXKEYS.ARE_TRANSLATIONS_LOADING, ONYXKEYS.SESSION, ONYXKEYS.STASHED_SESSION, - ONYXKEYS.IS_LOADING_APP, ONYXKEYS.HAS_LOADED_APP, ONYXKEYS.STASHED_CREDENTIALS, diff --git a/src/pages/settings/Subscription/SubscriptionSettingsPage.tsx b/src/pages/settings/Subscription/SubscriptionSettingsPage.tsx index 8c730add7d93..910da137e843 100644 --- a/src/pages/settings/Subscription/SubscriptionSettingsPage.tsx +++ b/src/pages/settings/Subscription/SubscriptionSettingsPage.tsx @@ -33,7 +33,7 @@ function SubscriptionSettingsPage({route}: SubscriptionSettingsPageProps) { useEffect(() => { openSubscriptionPage(); }, []); - const [isAppLoading] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: false}); + const [isAppLoading = true] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: false}); if (!subscriptionPlan && isAppLoading) { return ; From a9d5c5480524bd46b7242d1ad15d3688ef3960f9 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 13 Aug 2025 12:24:36 +0700 Subject: [PATCH 2/3] fix lint --- src/hooks/useSubscriptionPlan.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useSubscriptionPlan.ts b/src/hooks/useSubscriptionPlan.ts index 3f5d55487192..098c4ca95cbd 100644 --- a/src/hooks/useSubscriptionPlan.ts +++ b/src/hooks/useSubscriptionPlan.ts @@ -6,8 +6,8 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; import useOnyx from './useOnyx'; function useSubscriptionPlan() { - const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); - const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA); + const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false}); + const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA, {canBeMissing: true}); // Filter workspaces in which user is the owner and the type is either corporate (control) or team (collect) const ownerPolicies = useMemo(() => getOwnedPaidPolicies(policies, userMetadata?.accountID ?? -1), [policies, userMetadata?.accountID]); From 75945a071a9570907aea26f0c8fcd0914fb9e8f7 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 13 Aug 2025 12:30:42 +0700 Subject: [PATCH 3/3] fix lint --- src/hooks/useSubscriptionPlan.ts | 2 +- src/libs/PolicyUtils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useSubscriptionPlan.ts b/src/hooks/useSubscriptionPlan.ts index 098c4ca95cbd..a53b867b6973 100644 --- a/src/hooks/useSubscriptionPlan.ts +++ b/src/hooks/useSubscriptionPlan.ts @@ -10,7 +10,7 @@ function useSubscriptionPlan() { const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA, {canBeMissing: true}); // Filter workspaces in which user is the owner and the type is either corporate (control) or team (collect) - const ownerPolicies = useMemo(() => getOwnedPaidPolicies(policies, userMetadata?.accountID ?? -1), [policies, userMetadata?.accountID]); + const ownerPolicies = useMemo(() => getOwnedPaidPolicies(policies, userMetadata?.accountID), [policies, userMetadata?.accountID]); if (isEmptyObject(ownerPolicies)) { return null; diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index e77a1e1e46cd..0320321a134f 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -524,7 +524,7 @@ function isPaidGroupPolicy(policy: OnyxInputOrEntry | SearchPolicy): boo return policy?.type === CONST.POLICY.TYPE.TEAM || policy?.type === CONST.POLICY.TYPE.CORPORATE; } -function getOwnedPaidPolicies(policies: OnyxCollection | null, currentUserAccountID: number): Policy[] { +function getOwnedPaidPolicies(policies: OnyxCollection | null, currentUserAccountID: number | undefined): Policy[] { return Object.values(policies ?? {}).filter((policy): policy is Policy => isPolicyOwner(policy, currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID) && isPaidGroupPolicy(policy)); }