diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index bcba8774f96b..9136a5c3a31f 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -93,9 +93,6 @@ const ONYXKEYS = { * It is expected to provide a two-letter country code such as US for United States, and so on. */ COUNTRY: 'country', - /** Contains all the users settings for the Settings page and sub pages */ - USER: 'user', - /** Contains latitude and longitude of user's last known location */ USER_LOCATION: 'userLocation', @@ -1009,7 +1006,6 @@ type OnyxValuesMapping = { [ONYXKEYS.SCREEN_SHARE_REQUEST]: OnyxTypes.ScreenShareRequest; [ONYXKEYS.COUNTRY_CODE]: number; [ONYXKEYS.COUNTRY]: string; - [ONYXKEYS.USER]: OnyxTypes.User; [ONYXKEYS.USER_LOCATION]: OnyxTypes.UserLocation; [ONYXKEYS.LOGIN_LIST]: OnyxTypes.LoginList; [ONYXKEYS.PENDING_CONTACT_ACTION]: OnyxTypes.PendingContactAction; diff --git a/src/components/BookTravelButton.tsx b/src/components/BookTravelButton.tsx index a415b43e1b5f..03d2c17bd117 100644 --- a/src/components/BookTravelButton.tsx +++ b/src/components/BookTravelButton.tsx @@ -3,7 +3,6 @@ import {Str} from 'expensify-common'; import type {ReactElement} from 'react'; import React, {useCallback, useContext, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; -import useAccountValidation from '@hooks/useAccountValidation'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import usePermissions from '@hooks/usePermissions'; @@ -51,12 +50,13 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false}: B const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: false}); - const isUserValidated = useAccountValidation(); + const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); + const isUserValidated = account?.validated ?? false; + const primaryLogin = account?.primaryLogin ?? ''; const policy = usePolicy(activePolicyID); const [errorMessage, setErrorMessage] = useState(''); const [travelSettings] = useOnyx(ONYXKEYS.NVP_TRAVEL_SETTINGS, {canBeMissing: false}); - const [primaryLogin] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.primaryLogin, canBeMissing: false}); const [sessionEmail] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email, canBeMissing: false}); const primaryContactMethod = primaryLogin ?? sessionEmail ?? ''; const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext); diff --git a/src/components/SettlementButton/index.tsx b/src/components/SettlementButton/index.tsx index ba69591c0b26..1893a9a7dfd3 100644 --- a/src/components/SettlementButton/index.tsx +++ b/src/components/SettlementButton/index.tsx @@ -6,7 +6,6 @@ import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu'; import type {PaymentType} from '@components/ButtonWithDropdownMenu/types'; import * as Expensicons from '@components/Icon/Expensicons'; import KYCWall from '@components/KYCWall'; -import useAccountValidation from '@hooks/useAccountValidation'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -80,7 +79,7 @@ function SettlementButton({ // The app would crash due to subscribing to the entire report collection if chatReportID is an empty string. So we should have a fallback ID here. // eslint-disable-next-line rulesdir/no-default-id-values const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID || CONST.DEFAULT_NUMBER_ID}`, {canBeMissing: false}); - const isUserValidated = useAccountValidation(); + const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true}); const policyEmployeeAccountIDs = policyID ? getPolicyEmployeeAccountIDs(policyID) : []; const reportBelongsToWorkspace = policyID ? doesReportBelongToWorkspace(chatReport, policyEmployeeAccountIDs, policyID) : false; const policyIDKey = reportBelongsToWorkspace ? policyID : CONST.POLICY.ID_FAKE; diff --git a/src/hooks/useAccountValidation.tsx b/src/hooks/useAccountValidation.tsx deleted file mode 100644 index 74f0ad3fe998..000000000000 --- a/src/hooks/useAccountValidation.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {useOnyx} from 'react-native-onyx'; -import ONYXKEYS from '@src/ONYXKEYS'; - -// TODO: Remove/Update this hook once we remove the user data and migrate to account data in https://github.com/Expensify/App/issues/59277 -function useAccountValidation() { - // Some places are using the current value to compare, so we shouldn't cast to boolean - const [isAccountValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true}); - const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => user?.validated, canBeMissing: true}); - - return isAccountValidated ?? isUserValidated; -} - -export default useAccountValidation; diff --git a/src/pages/AddPersonalBankAccountPage.tsx b/src/pages/AddPersonalBankAccountPage.tsx index 2a4af0259bc8..44e80c339dfe 100644 --- a/src/pages/AddPersonalBankAccountPage.tsx +++ b/src/pages/AddPersonalBankAccountPage.tsx @@ -9,7 +9,6 @@ import InputWrapper from '@components/Form/InputWrapper'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; -import useAccountValidation from '@hooks/useAccountValidation'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import getPlaidOAuthReceivedRedirectURI from '@libs/getPlaidOAuthReceivedRedirectURI'; @@ -27,9 +26,9 @@ function AddPersonalBankAccountPage() { const styles = useThemeStyles(); const {translate} = useLocalize(); const [selectedPlaidAccountId, setSelectedPlaidAccountId] = useState(''); - const isUserValidated = useAccountValidation(); - const [personalBankAccount] = useOnyx(ONYXKEYS.PERSONAL_BANK_ACCOUNT); - const [plaidData] = useOnyx(ONYXKEYS.PLAID_DATA); + const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: false}); + const [personalBankAccount] = useOnyx(ONYXKEYS.PERSONAL_BANK_ACCOUNT, {canBeMissing: true}); + const [plaidData] = useOnyx(ONYXKEYS.PLAID_DATA, {canBeMissing: true}); const shouldShowSuccess = personalBankAccount?.shouldShowSuccess ?? false; const topmostFullScreenRoute = navigationRef.current?.getRootState()?.routes.findLast((route) => isFullScreenName(route.name)); diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 8be846692bb2..96adbed631a9 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -69,14 +69,9 @@ function ProfilePage({route}: ProfilePageProps) { const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: true}); const [personalDetailsMetadata] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_METADATA, {canBeMissing: true}); const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false}); - const [isDebugModeEnabled] = useOnyx(ONYXKEYS.ACCOUNT, { - selector: (account) => !!account?.isDebugModeEnabled, - canBeMissing: true, - }); - const [guideCalendarLink] = useOnyx(ONYXKEYS.ACCOUNT, { - selector: (account) => account?.guideCalendarLink, - canBeMissing: true, - }); + const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); + const isDebugModeEnabled = !!account?.isDebugModeEnabled; + const guideCalendarLink = account?.guideCalendarLink ?? ''; const accountID = Number(route.params?.accountID ?? CONST.DEFAULT_NUMBER_ID); const isCurrentUser = session?.accountID === accountID; diff --git a/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx b/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx index 1c4adf11ab5e..fd80c1d76236 100644 --- a/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx +++ b/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx @@ -15,7 +15,6 @@ import Section from '@components/Section'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; import ValidateCodeActionModal from '@components/ValidateCodeActionModal'; -import useAccountValidation from '@hooks/useAccountValidation'; import useLocalize from '@hooks/useLocalize'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; @@ -98,7 +97,7 @@ function VerifiedBankAccountFlowEntryPoint({ const pendingAction = reimbursementAccount?.pendingAction ?? null; const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); const optionPressed = useRef(''); - const isAccountValidated = useAccountValidation(); + const isAccountValidated = account?.validated ?? false; const contactMethod = account?.primaryLogin ?? ''; const loginData = useMemo(() => loginList?.[contactMethod], [loginList, contactMethod]); diff --git a/src/pages/Travel/WorkspaceAddressForTravelPage.tsx b/src/pages/Travel/WorkspaceAddressForTravelPage.tsx index d50debadc6a5..1f81d36424e0 100644 --- a/src/pages/Travel/WorkspaceAddressForTravelPage.tsx +++ b/src/pages/Travel/WorkspaceAddressForTravelPage.tsx @@ -1,7 +1,6 @@ import React from 'react'; import {useOnyx} from 'react-native-onyx'; import type {FormOnyxValues} from '@components/Form/types'; -import useAccountValidation from '@hooks/useAccountValidation'; import useLocalize from '@hooks/useLocalize'; import usePolicy from '@hooks/usePolicy'; import Navigation from '@libs/Navigation/Navigation'; @@ -18,9 +17,9 @@ type WorkspaceAddressForTravelPageProps = PlatformStackScreenProps account?.validated, canBeMissing: true}); const updatePolicyAddress = (values: FormOnyxValues) => { if (!policy) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index a2e7cda4057f..558617c3317d 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -1,7 +1,6 @@ import React, {useMemo} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {useBlockedFromConcierge} from '@components/OnyxProvider'; -import useAccountValidation from '@hooks/useAccountValidation'; import useOnyx from '@hooks/useOnyx'; import useReportIsArchived from '@hooks/useReportIsArchived'; import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage'; @@ -57,7 +56,7 @@ function ReportActionItem({action, report, ...props}: PureReportActionItemProps) // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- This is needed to prevent the app from crashing when the app is using imported state. const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || undefined}`, {canBeMissing: true}); - const isUserValidated = useAccountValidation(); + const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true}); // The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || undefined}`, {canBeMissing: true}); diff --git a/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx b/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx index 7a916666b46e..ca8d09fb3b4d 100644 --- a/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx +++ b/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx @@ -13,7 +13,6 @@ import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import ValidateCodeActionModal from '@components/ValidateCodeActionModal'; -import useAccountValidation from '@hooks/useAccountValidation'; import useBeforeRemove from '@hooks/useBeforeRemove'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -53,7 +52,7 @@ function NewContactMethodPage({route, navigation}: NewContactMethodPageProps) { const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); const loginData = loginList?.[pendingContactAction?.contactMethod ?? contactMethod]; const validateLoginError = getLatestErrorField(loginData, 'addedLogin'); - const isUserValidated = useAccountValidation(); + const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true}); const navigateBackTo = route?.params?.backTo ?? ROUTES.SETTINGS_PROFILE.getRoute(); diff --git a/src/pages/settings/Security/TwoFactorAuth/CopyCodesPage.tsx b/src/pages/settings/Security/TwoFactorAuth/CopyCodesPage.tsx index b2b89fd912c5..a582011ce8a5 100644 --- a/src/pages/settings/Security/TwoFactorAuth/CopyCodesPage.tsx +++ b/src/pages/settings/Security/TwoFactorAuth/CopyCodesPage.tsx @@ -11,7 +11,6 @@ import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; import Text from '@components/Text'; import ValidateCodeActionModal from '@components/ValidateCodeActionModal'; -import useAccountValidation from '@hooks/useAccountValidation'; import useBeforeRemove from '@hooks/useBeforeRemove'; import useLocalize from '@hooks/useLocalize'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; @@ -45,7 +44,7 @@ function CopyCodesPage({route}: TwoFactorAuthPageProps) { const [account, accountMetadata] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); - const isUserValidated = useAccountValidation(); + const isUserValidated = account?.validated ?? false; const contactMethod = account?.primaryLogin ?? ''; const loginData = useMemo(() => loginList?.[contactMethod], [loginList, contactMethod]); diff --git a/src/pages/settings/Wallet/PaymentMethodList.tsx b/src/pages/settings/Wallet/PaymentMethodList.tsx index 99b3e4abafcf..9c3658d45e88 100644 --- a/src/pages/settings/Wallet/PaymentMethodList.tsx +++ b/src/pages/settings/Wallet/PaymentMethodList.tsx @@ -13,7 +13,6 @@ import * as Expensicons from '@components/Icon/Expensicons'; import MenuItem from '@components/MenuItem'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import Text from '@components/Text'; -import useAccountValidation from '@hooks/useAccountValidation'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import type {FormattedSelectedPaymentMethodIcon} from '@hooks/usePaymentMethodState/types'; @@ -199,15 +198,15 @@ function PaymentMethodList({ const {isOffline} = useNetwork(); const illustrations = useThemeIllustrations(); - const isUserValidated = useAccountValidation(); - const [bankAccountList = {}, bankAccountListResult] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); - const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET); + const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true}); + const [bankAccountList = {}, bankAccountListResult] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: true}); + const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET, {canBeMissing: true}); const isLoadingBankAccountList = isLoadingOnyxValue(bankAccountListResult); - const [cardList = {}, cardListResult] = useOnyx(ONYXKEYS.CARD_LIST); + const [cardList = {}, cardListResult] = useOnyx(ONYXKEYS.CARD_LIST, {canBeMissing: true}); const isLoadingCardList = isLoadingOnyxValue(cardListResult); // Temporarily disabled because P2P debit cards are disabled. // const [fundList = {}] = useOnyx(ONYXKEYS.FUND_LIST); - const [isLoadingPaymentMethods = true, isLoadingPaymentMethodsResult] = useOnyx(ONYXKEYS.IS_LOADING_PAYMENT_METHODS); + const [isLoadingPaymentMethods = true, isLoadingPaymentMethodsResult] = useOnyx(ONYXKEYS.IS_LOADING_PAYMENT_METHODS, {canBeMissing: true}); const isLoadingPaymentMethodsOnyx = isLoadingOnyxValue(isLoadingPaymentMethodsResult); const filteredPaymentMethods = useMemo(() => { diff --git a/src/pages/settings/Wallet/VerifyAccountPage.tsx b/src/pages/settings/Wallet/VerifyAccountPage.tsx index 36cc7f951673..dfa69b57adca 100644 --- a/src/pages/settings/Wallet/VerifyAccountPage.tsx +++ b/src/pages/settings/Wallet/VerifyAccountPage.tsx @@ -4,7 +4,6 @@ import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ValidateCodeActionModal from '@components/ValidateCodeActionModal'; -import useAccountValidation from '@hooks/useAccountValidation'; import useBeforeRemove from '@hooks/useBeforeRemove'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -26,7 +25,7 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { const {translate} = useLocalize(); const loginData = loginList?.[contactMethod]; const validateLoginError = getEarliestErrorField(loginData, 'validateLogin'); - const isUserValidated = useAccountValidation(); + const isUserValidated = account?.validated ?? false; const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(true); const navigateForwardTo = route.params?.forwardTo; diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx index 00ca6052592d..c2bb15df44b7 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx @@ -24,7 +24,6 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; import Text from '@components/Text'; -import useAccountValidation from '@hooks/useAccountValidation'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePaymentMethodState from '@hooks/usePaymentMethodState'; @@ -56,16 +55,17 @@ type WalletPageProps = { }; function WalletPage({shouldListenForResize = false}: WalletPageProps) { - const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {initialValue: {}}); - const [cardList] = useOnyx(ONYXKEYS.CARD_LIST, {initialValue: {}}); - const [fundList] = useOnyx(ONYXKEYS.FUND_LIST, {initialValue: {}}); - const [isLoadingPaymentMethods] = useOnyx(ONYXKEYS.IS_LOADING_PAYMENT_METHODS, {initialValue: true}); - const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET); - const [walletTerms] = useOnyx(ONYXKEYS.WALLET_TERMS, {initialValue: {}}); - const isUserValidated = useAccountValidation(); - const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); - - const [isActingAsDelegate] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => !!account?.delegatedAccess?.delegate}); + const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {initialValue: {}, canBeMissing: true}); + const [cardList] = useOnyx(ONYXKEYS.CARD_LIST, {initialValue: {}, canBeMissing: true}); + const [fundList] = useOnyx(ONYXKEYS.FUND_LIST, {initialValue: {}, canBeMissing: true}); + const [isLoadingPaymentMethods] = useOnyx(ONYXKEYS.IS_LOADING_PAYMENT_METHODS, {initialValue: true, canBeMissing: true}); + const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET, {canBeMissing: true}); + const [walletTerms] = useOnyx(ONYXKEYS.WALLET_TERMS, {initialValue: {}, canBeMissing: true}); + const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: false}); + const [userAccount] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); + const isUserValidated = userAccount?.validated ?? false; + const isActingAsDelegate = !!userAccount?.delegatedAccess?.delegate || false; + const [isNoDelegateAccessMenuVisible, setIsNoDelegateAccessMenuVisible] = useState(false); const theme = useTheme(); diff --git a/src/pages/signin/SignInPage.tsx b/src/pages/signin/SignInPage.tsx index 1eb898e013e3..3a5ee28391f4 100644 --- a/src/pages/signin/SignInPage.tsx +++ b/src/pages/signin/SignInPage.tsx @@ -8,7 +8,6 @@ import CustomStatusBarAndBackground from '@components/CustomStatusBarAndBackgrou import ScreenWrapper from '@components/ScreenWrapper'; import ThemeProvider from '@components/ThemeProvider'; import ThemeStylesProvider from '@components/ThemeStylesProvider'; -import useAccountValidation from '@hooks/useAccountValidation'; import useLocalize from '@hooks/useLocalize'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useSafeAreaInsets from '@hooks/useSafeAreaInsets'; @@ -155,7 +154,7 @@ function SignInPage({shouldEnableMaxHeight = true}: SignInPageInnerProps, ref: F const validateCodeFormRef = useRef(null); const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); - const isAccountValidated = useAccountValidation(); + const isAccountValidated = account?.validated ?? false; const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS, {canBeMissing: true}); /** This variable is only added to make sure the component is re-rendered diff --git a/src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx b/src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx index b7bb061dc678..ece8eef2087e 100644 --- a/src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx +++ b/src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx @@ -9,7 +9,6 @@ import * as Expensicons from '@components/Icon/Expensicons'; import MenuItem from '@components/MenuItem'; import Popover from '@components/Popover'; import Section from '@components/Section'; -import useAccountValidation from '@hooks/useAccountValidation'; import useLocalize from '@hooks/useLocalize'; import usePaymentMethodState from '@hooks/usePaymentMethodState'; import type {FormattedSelectedPaymentMethod, FormattedSelectedPaymentMethodIcon} from '@hooks/usePaymentMethodState/types'; @@ -38,9 +37,9 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps) const {shouldUseNarrowLayout} = useResponsiveLayout(); const {windowWidth} = useWindowDimensions(); const {translate} = useLocalize(); - const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); - const isUserValidated = useAccountValidation(); - const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {canBeMissing: true}); + const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true}); + const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: true}); const {paymentMethod, setPaymentMethod, resetSelectedPaymentMethodData} = usePaymentMethodState(); const addPaymentMethodAnchorRef = useRef(null); const paymentMethodButtonRef = useRef(null); diff --git a/src/types/onyx/User.ts b/src/types/onyx/User.ts deleted file mode 100644 index 48769ffcbf39..000000000000 --- a/src/types/onyx/User.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** Model of user data */ -/** - * @deprecated This Model is currently being deprecated in favor of using the Account Key. Please use that instead. - * See the following Github issue for more info: https://github.com/Expensify/App/issues/59277 - */ -type User = { - /** Whether or not the user is subscribed to news updates */ - isSubscribedToNewsletter: boolean; - - /** Whether we should use the staging version of the secure API server */ - shouldUseStagingServer?: boolean; - - /** Is the user account validated? */ - validated: boolean; - - /** Whether or not the user is on a public domain email account or not */ - isFromPublicDomain: boolean; - - /** Whether or not the user use expensify card */ - isUsingExpensifyCard: boolean; - - /** Whever Expensify Card approval flow is ongoing - checking loginList for private domains */ - isCheckingDomain?: boolean; - - /** Whether or not the user has lounge access */ - hasLoungeAccess?: boolean; - - /** error associated with adding a secondary login */ - error?: string; - - /** Whether the form is being submitted */ - loading?: boolean; - - /** Whether the user is Expensify Guide */ - isGuide?: boolean; - - /** Whether the debug mode is currently enabled */ - isDebugModeEnabled?: boolean; - - /** If user has accesible policies on a private domain */ - hasAccessibleDomainPolicies?: boolean; -}; - -// eslint-disable-next-line deprecation/deprecation -export default User; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index ebf019ccc04f..48a138bbb0a7 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -107,7 +107,6 @@ import type TransactionViolations from './TransactionViolation'; import type TravelProvisioning from './TravelProvisioning'; import type {TravelSettings} from './TravelSettings'; import type TryNewDot from './TryNewDot'; -import type User from './User'; import type UserLocation from './UserLocation'; import type UserMetadata from './UserMetadata'; import type UserWallet from './UserWallet'; @@ -210,7 +209,6 @@ export type { TransactionViolation, TransactionViolations, TravelSettings, - User, UserLocation, UserMetadata, UserWallet,