Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/components/BookTravelButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<string | ReactElement>('');
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);
Expand Down
3 changes: 1 addition & 2 deletions src/components/SettlementButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 0 additions & 13 deletions src/hooks/useAccountValidation.tsx

This file was deleted.

7 changes: 3 additions & 4 deletions src/pages/AddPersonalBankAccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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));

Expand Down
11 changes: 3 additions & 8 deletions src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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]);
Expand Down
5 changes: 2 additions & 3 deletions src/pages/Travel/WorkspaceAddressForTravelPage.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,9 +17,9 @@ type WorkspaceAddressForTravelPageProps = PlatformStackScreenProps<TravelNavigat

function WorkspaceAddressForTravelPage({route}: WorkspaceAddressForTravelPageProps) {
const {translate} = useLocalize();
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const policy = usePolicy(activePolicyID);
const isUserValidated = useAccountValidation();
const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true});

const updatePolicyAddress = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.HOME_ADDRESS_FORM>) => {
if (!policy) {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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]);
Expand Down
11 changes: 5 additions & 6 deletions src/pages/settings/Wallet/PaymentMethodList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(() => {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Wallet/VerifyAccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
22 changes: 11 additions & 11 deletions src/pages/settings/Wallet/WalletPage/WalletPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/pages/signin/SignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -155,7 +154,7 @@ function SignInPage({shouldEnableMaxHeight = true}: SignInPageInnerProps, ref: F
const validateCodeFormRef = useRef<BaseValidateCodeFormRef>(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
Expand Down
7 changes: 3 additions & 4 deletions src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<HTMLDivElement | null>(null);
Expand Down
Loading