diff --git a/src/components/HTMLEngineProvider/htmlEngineUtils.ts b/src/components/HTMLEngineProvider/htmlEngineUtils.ts index f94339820fbf..24f6e4bbc81b 100644 --- a/src/components/HTMLEngineProvider/htmlEngineUtils.ts +++ b/src/components/HTMLEngineProvider/htmlEngineUtils.ts @@ -71,4 +71,4 @@ function isDeletedNode(tnode: TNode): boolean { return 'textDecorationLine' in parentStyle && parentStyle.textDecorationLine === 'line-through'; } -export {computeEmbeddedMaxWidth, isChildOfComment, isCommentTag, isChildOfH1, isDeletedNode, isChildOfTaskTitle}; +export {computeEmbeddedMaxWidth, isChildOfComment, isChildOfH1, isDeletedNode, isChildOfTaskTitle}; diff --git a/src/components/InputBlurContext/index.tsx b/src/components/InputBlurContext/index.tsx index 949c7029d849..06d76cbd4f56 100644 --- a/src/components/InputBlurContext/index.tsx +++ b/src/components/InputBlurContext/index.tsx @@ -29,4 +29,4 @@ function useInputBlurContext() { return useContext(InputBlurContext); } -export {InputBlurContext, useInputBlurContext, InputBlurContextProvider}; +export {useInputBlurContext, InputBlurContextProvider}; diff --git a/src/components/MultiGestureCanvas/index.tsx b/src/components/MultiGestureCanvas/index.tsx index 7e5c5d2365d8..7a21eafa0a08 100644 --- a/src/components/MultiGestureCanvas/index.tsx +++ b/src/components/MultiGestureCanvas/index.tsx @@ -10,7 +10,7 @@ import Animated, {cancelAnimation, runOnUI, useAnimatedReaction, useAnimatedStyl import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import type ChildrenProps from '@src/types/utils/ChildrenProps'; -import {DEFAULT_ZOOM_RANGE, SPRING_CONFIG, ZOOM_RANGE_BOUNCE_FACTORS} from './constants'; +import {DEFAULT_ZOOM_RANGE, SPRING_CONFIG} from './constants'; import type {CanvasSize, ContentSize, OnScaleChangedCallback, OnSwipeDownCallback, OnTapCallback, ZoomRange} from './types'; import usePanGesture from './usePanGesture'; import usePinchGesture from './usePinchGesture'; @@ -289,5 +289,5 @@ function MultiGestureCanvas({ MultiGestureCanvas.displayName = 'MultiGestureCanvas'; export default MultiGestureCanvas; -export {DEFAULT_ZOOM_RANGE, ZOOM_RANGE_BOUNCE_FACTORS}; +export {DEFAULT_ZOOM_RANGE}; export type {MultiGestureCanvasProps}; diff --git a/src/components/OptionListContextProvider.tsx b/src/components/OptionListContextProvider.tsx index 6a52dcb204ab..d74fac25e195 100644 --- a/src/components/OptionListContextProvider.tsx +++ b/src/components/OptionListContextProvider.tsx @@ -46,8 +46,8 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { reports: [], personalDetails: [], }); - const [preferredLocale] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE); - const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); + const [preferredLocale] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE, {canBeMissing: true}); + const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); const personalDetails = usePersonalDetails(); const prevPersonalDetails = usePrevious(personalDetails); @@ -182,7 +182,7 @@ const useOptionsListContext = () => useContext(OptionsListContext); const useOptionsList = (options?: {shouldInitialize: boolean}) => { const {shouldInitialize = true} = options ?? {}; const {initializeOptions, options: optionsList, areOptionsInitialized, resetOptions} = useOptionsListContext(); - const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); + const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); useEffect(() => { if (!shouldInitialize || areOptionsInitialized || isLoadingApp) { @@ -202,4 +202,4 @@ const useOptionsList = (options?: {shouldInitialize: boolean}) => { export default OptionsListContextProvider; -export {useOptionsListContext, useOptionsList, OptionsListContext}; +export {useOptionsList, OptionsListContext}; diff --git a/src/components/ThreeDotsMenu/index.tsx b/src/components/ThreeDotsMenu/index.tsx index 3c5957d209ac..775cb76cf298 100644 --- a/src/components/ThreeDotsMenu/index.tsx +++ b/src/components/ThreeDotsMenu/index.tsx @@ -62,7 +62,7 @@ function ThreeDotsMenu({ setPopupMenuVisible(false); }; - useImperativeHandle(threeDotsMenuRef, () => ({ + useImperativeHandle(threeDotsMenuRef as React.RefObject<{hidePopoverMenu: () => void; isPopupMenuVisible: boolean}> | undefined, () => ({ isPopupMenuVisible, hidePopoverMenu, })); diff --git a/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx b/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx index 1ec4164b3d17..2017c6b38cec 100644 --- a/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx +++ b/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx @@ -108,7 +108,9 @@ function BaseValidateCodeForm({ const [formError, setFormError] = useState({}); const [validateCode, setValidateCode] = useState(''); const inputValidateCodeRef = useRef(null); - const [account = {}] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); + const [account = {}] = useOnyx(ONYXKEYS.ACCOUNT, { + canBeMissing: true, + }); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- nullish coalescing doesn't achieve the same result in this case const shouldDisableResendValidateCode = !!isOffline || account?.isLoading; const focusTimeoutRef = useRef(null); diff --git a/src/components/withEnvironment.tsx b/src/components/withEnvironment.tsx index bd57ed5da696..d8c620c964cb 100644 --- a/src/components/withEnvironment.tsx +++ b/src/components/withEnvironment.tsx @@ -1,8 +1,7 @@ -import type {ComponentType, ForwardedRef, ReactElement, ReactNode, RefAttributes} from 'react'; -import React, {createContext, forwardRef, useContext, useEffect, useMemo, useState} from 'react'; +import type {ReactElement, ReactNode} from 'react'; +import React, {createContext, useEffect, useMemo, useState} from 'react'; import type {ValueOf} from 'type-fest'; -import * as Environment from '@libs/Environment/Environment'; -import getComponentDisplayName from '@libs/getComponentDisplayName'; +import {getEnvironment, getEnvironmentURL} from '@libs/Environment/Environment'; import CONST from '@src/CONST'; type EnvironmentProviderProps = { @@ -30,8 +29,8 @@ function EnvironmentProvider({children}: EnvironmentProviderProps): ReactElement const [environmentURL, setEnvironmentURL] = useState(CONST.NEW_EXPENSIFY_URL); useEffect(() => { - Environment.getEnvironment().then(setEnvironment); - Environment.getEnvironmentURL().then(setEnvironmentURL); + getEnvironment().then(setEnvironment); + getEnvironmentURL().then(setEnvironmentURL); }, []); const contextValue = useMemo( @@ -47,26 +46,5 @@ function EnvironmentProvider({children}: EnvironmentProviderProps): ReactElement EnvironmentProvider.displayName = 'EnvironmentProvider'; -export default function withEnvironment( - WrappedComponent: ComponentType>, -): (props: Omit & React.RefAttributes) => ReactElement | null { - function WithEnvironment(props: Omit, ref: ForwardedRef): ReactElement { - const {environment, environmentURL} = useContext(EnvironmentContext); - return ( - - ); - } - - WithEnvironment.displayName = `withEnvironment(${getComponentDisplayName(WrappedComponent)})`; - - return forwardRef(WithEnvironment); -} - export {EnvironmentContext, EnvironmentProvider}; export type {EnvironmentContextValue}; diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts deleted file mode 100644 index 111674b8ffb6..000000000000 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ /dev/null @@ -1,9 +0,0 @@ -type UpdatePolicyConnectionConfigParams = { - policyID: string; - connectionName: string; - settingName: string; - settingValue: string; - idempotencyKey: string; -}; - -export default UpdatePolicyConnectionConfigParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index bedbac49a56f..2823589b47b4 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -230,7 +230,6 @@ export type {default as SetPolicyForeignCurrencyDefaultParams} from './SetPolicy export type {default as SetPolicyCurrencyDefaultParams} from './SetPolicyCurrencyDefaultParams'; export type {default as UpdateQuickbooksOnlineGenericTypeParams} from './UpdateQuickbooksOnlineGenericTypeParams'; export type {default as UpdateQuickbooksDesktopGenericTypeParams} from './UpdateQuickbooksDesktopGenericTypeParams'; -export type {default as UpdatePolicyConnectionConfigParams} from './UpdatePolicyConnectionConfigParams'; export type {default as UpdateManyPolicyConnectionConfigurationsParams} from './UpdateManyPolicyConnectionConfigurationsParams'; export type {default as RemovePolicyConnectionParams} from './RemovePolicyConnectionParams'; export type {default as RenamePolicyTaxParams} from './RenamePolicyTaxParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 7aabb68d618d..5d298603d50f 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -255,7 +255,6 @@ const WRITE_COMMANDS = { ACCEPT_JOIN_REQUEST: 'AcceptJoinRequest', DECLINE_JOIN_REQUEST: 'DeclineJoinRequest', CREATE_POLICY_TAX: 'CreatePolicyTax', - UPDATE_POLICY_CONNECTION_CONFIG: 'UpdatePolicyConnectionConfiguration', UPDATE_QUICKBOOKS_ONLINE_ENABLE_NEW_CATEGORIES: 'UpdateQuickbooksOnlineEnableNewCategories', UPDATE_QUICKBOOKS_ONLINE_AUTO_CREATE_VENDOR: 'UpdateQuickbooksOnlineAutoCreateVendor', UPDATE_QUICKBOOKS_ONLINE_REIMBURSABLE_EXPENSES_ACCOUNT: 'UpdateQuickbooksOnlineReimbursableExpensesAccount', @@ -776,7 +775,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_SYNC_CUSTOMERS]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_SYNC_ITEMS]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_EXPORT]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; - [WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG]: Parameters.UpdatePolicyConnectionConfigParams; [WRITE_COMMANDS.UPDATE_MANY_POLICY_CONNECTION_CONFIGS]: Parameters.UpdateManyPolicyConnectionConfigurationsParams; [WRITE_COMMANDS.REMOVE_POLICY_CONNECTION]: Parameters.RemovePolicyConnectionParams; [WRITE_COMMANDS.UPDATE_POLICY_DISTANCE_RATE_VALUE]: Parameters.UpdatePolicyDistanceRateValueParams; diff --git a/src/libs/CardUtils.ts b/src/libs/CardUtils.ts index faddf805f0f1..296d32fa1eac 100644 --- a/src/libs/CardUtils.ts +++ b/src/libs/CardUtils.ts @@ -63,14 +63,6 @@ function isExpensifyCard(cardID?: number) { return card.bank === CONST.EXPENSIFY_CARD.BANK; } -/** - * @param cardID - * @returns boolean if the cardID is in the cardList from ONYX. Includes Expensify Cards. - */ -function isCorporateCard(cardID: number) { - return !!allCards[cardID]; -} - /** * @param cardID * @returns string in format % - %. @@ -92,10 +84,6 @@ function isCard(item: Card | Record): item is Card { return typeof item === 'object' && 'cardID' in item && !!item.cardID && 'bank' in item && !!item.bank; } -function isCardIssued(card: Card) { - return !!card?.nameValuePairs?.isVirtual || card?.state !== CONST.EXPENSIFY_CARD.STATE.STATE_NOT_ISSUED; -} - function isCardHiddenFromSearch(card: Card) { return !card?.nameValuePairs?.isVirtual && CONST.EXPENSIFY_CARD.HIDDEN_FROM_SEARCH_STATES.includes(card.state ?? 0); } @@ -228,24 +216,6 @@ function lastFourNumbersFromCardName(cardName: string | undefined): string { return match[1]; } -/** - * Finds physical card in a list of cards - * - * @returns a physical card object (or undefined if none is found) - */ -function findPhysicalCard(cards: Card[]) { - return cards.find((card) => !card?.nameValuePairs?.isVirtual); -} - -/** - * Checks if any of the cards in the list have detected fraud - * - * @param cardList - collection of assigned cards - */ -function hasDetectedFraud(cardList: Record): boolean { - return Object.values(cardList).some((card) => card.fraud !== CONST.EXPENSIFY_CARD.FRAUD_TYPES.NONE); -} - function getMCardNumberString(cardNumber: string): string { return cardNumber.replace(/\s/g, ''); } @@ -610,7 +580,6 @@ function getFundIdFromSettingsKey(key: string) { export { isExpensifyCard, - isCorporateCard, getDomainCards, formatCardExpiration, getMonthFromExpirationDateString, @@ -618,8 +587,6 @@ export { maskCard, maskCardNumber, getCardDescription, - findPhysicalCard, - hasDetectedFraud, getMCardNumberString, getTranslationKeyForLimitType, getEligibleBankAccountsForCard, @@ -641,7 +608,6 @@ export { mergeCardListWithWorkspaceFeeds, isCard, getAllCardsForWorkspace, - isCardIssued, isCardHiddenFromSearch, getFeedType, flatAllCardsList, diff --git a/src/libs/ComponentUtils/index.native.ts b/src/libs/ComponentUtils/index.native.ts index 7a3492c20ded..60be12c2a978 100644 --- a/src/libs/ComponentUtils/index.native.ts +++ b/src/libs/ComponentUtils/index.native.ts @@ -1,10 +1,8 @@ import type {Component} from 'react'; import type {AnimatedRef} from 'react-native-reanimated'; import {dispatchCommand} from 'react-native-reanimated'; -import type {AccessibilityRoleForm, NewPasswordAutocompleteType, PasswordAutocompleteType} from './types'; +import type AccessibilityRoleForm from './types'; -const PASSWORD_AUTOCOMPLETE_TYPE: PasswordAutocompleteType = 'password'; -const NEW_PASSWORD_AUTOCOMPLETE_TYPE: NewPasswordAutocompleteType = 'password-new'; const ACCESSIBILITY_ROLE_FORM: AccessibilityRoleForm = 'none'; /** @@ -17,4 +15,4 @@ function forceClearInput(animatedInputRef: AnimatedRef) { dispatchCommand(animatedInputRef, 'clear'); } -export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE, forceClearInput}; +export {ACCESSIBILITY_ROLE_FORM, forceClearInput}; diff --git a/src/libs/ComponentUtils/index.ts b/src/libs/ComponentUtils/index.ts index 518791b572c9..c2d235dcaaa9 100644 --- a/src/libs/ComponentUtils/index.ts +++ b/src/libs/ComponentUtils/index.ts @@ -1,12 +1,10 @@ import type {Component} from 'react'; import type {AnimatedRef} from 'react-native-reanimated'; -import type {AccessibilityRoleForm, NewPasswordAutocompleteType, PasswordAutocompleteType} from './types'; +import type AccessibilityRoleForm from './types'; /** * Web password field needs `current-password` as autocomplete type which is not supported on native */ -const PASSWORD_AUTOCOMPLETE_TYPE: PasswordAutocompleteType = 'current-password'; -const NEW_PASSWORD_AUTOCOMPLETE_TYPE: NewPasswordAutocompleteType = 'new-password'; const ACCESSIBILITY_ROLE_FORM: AccessibilityRoleForm = 'form'; function forceClearInput(animatedInputRef: AnimatedRef) { @@ -18,4 +16,4 @@ function forceClearInput(animatedInputRef: AnimatedRef) { } } -export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE, forceClearInput}; +export {ACCESSIBILITY_ROLE_FORM, forceClearInput}; diff --git a/src/libs/ComponentUtils/types.ts b/src/libs/ComponentUtils/types.ts index 6efc53c2fdf7..30615e64b6d1 100644 --- a/src/libs/ComponentUtils/types.ts +++ b/src/libs/ComponentUtils/types.ts @@ -1,5 +1,3 @@ -type PasswordAutocompleteType = 'current-password' | 'password'; -type NewPasswordAutocompleteType = 'new-password' | 'password-new'; type AccessibilityRoleForm = 'form' | 'none'; -export type {PasswordAutocompleteType, NewPasswordAutocompleteType, AccessibilityRoleForm}; +export default AccessibilityRoleForm; diff --git a/src/libs/E2E/reactNativeLaunchingTest.ts b/src/libs/E2E/reactNativeLaunchingTest.ts index 50a0b3063ba9..507067ff4c31 100644 --- a/src/libs/E2E/reactNativeLaunchingTest.ts +++ b/src/libs/E2E/reactNativeLaunchingTest.ts @@ -5,7 +5,7 @@ * By doing this, we avoid bundling any E2E testing code * into the actual release app. */ -import * as Metrics from '@libs/Metrics'; +import canCapturePerformanceMetrics from '@libs/Metrics'; import Performance from '@libs/Performance'; import Config from 'react-native-config'; import E2EConfig from '../../../tests/e2e/config'; @@ -19,7 +19,7 @@ console.debug('==== Running e2e test ===='); console.debug('=========================='); // Check if the performance module is available -if (!Metrics.canCapturePerformanceMetrics()) { +if (!canCapturePerformanceMetrics()) { throw new Error('Performance module not available! Please set CAPTURE_METRICS=true in your environment file!'); } diff --git a/src/libs/EmojiUtils.tsx b/src/libs/EmojiUtils.tsx index a8fb6f7a92b3..42c04b6db609 100644 --- a/src/libs/EmojiUtils.tsx +++ b/src/libs/EmojiUtils.tsx @@ -146,13 +146,6 @@ const getEmojiUnicode = memoize( {monitoringName: 'getEmojiUnicode'}, ); -/** - * Function to remove Skin Tone and utf16 surrogates from Emoji - */ -function trimEmojiUnicode(emojiCode: string): string { - return emojiCode.replace(/(fe0f|1f3fb|1f3fc|1f3fd|1f3fe|1f3ff)$/, '').trim(); -} - /** * Validates first character is emoji in text string */ @@ -687,7 +680,6 @@ export { containsOnlyEmojis, replaceEmojis, suggestEmojis, - trimEmojiUnicode, getEmojiCodeWithSkinColor, getPreferredSkinToneIndex, getPreferredEmojiCode, diff --git a/src/libs/Metrics/index.native.ts b/src/libs/Metrics/index.native.ts index a1d008da653b..1749761de836 100644 --- a/src/libs/Metrics/index.native.ts +++ b/src/libs/Metrics/index.native.ts @@ -1,14 +1,9 @@ import CONFIG from '@src/CONFIG'; -import type {CanCaptureOnyxMetrics, CanCapturePerformanceMetrics} from './types'; +import type CanCapturePerformanceMetrics from './types'; /** * Is capturing performance stats enabled. */ const canCapturePerformanceMetrics: CanCapturePerformanceMetrics = () => CONFIG.CAPTURE_METRICS; -/** - * Is capturing Onyx stats enabled. - */ -const canCaptureOnyxMetrics: CanCaptureOnyxMetrics = () => CONFIG.ONYX_METRICS; - -export {canCapturePerformanceMetrics, canCaptureOnyxMetrics}; +export default canCapturePerformanceMetrics; diff --git a/src/libs/Metrics/index.ts b/src/libs/Metrics/index.ts index 51248b891d81..658888b740f8 100644 --- a/src/libs/Metrics/index.ts +++ b/src/libs/Metrics/index.ts @@ -1,9 +1,6 @@ -import CONFIG from '@src/CONFIG'; -import type {CanCaptureOnyxMetrics, CanCapturePerformanceMetrics} from './types'; +import type CanCapturePerformanceMetrics from './types'; // We don't capture performance metrics on web as there are enough tools available const canCapturePerformanceMetrics: CanCapturePerformanceMetrics = () => false; -const canCaptureOnyxMetrics: CanCaptureOnyxMetrics = () => CONFIG.ONYX_METRICS; - -export {canCapturePerformanceMetrics, canCaptureOnyxMetrics}; +export default canCapturePerformanceMetrics; diff --git a/src/libs/Metrics/types.ts b/src/libs/Metrics/types.ts index 61b1400ae9f8..15e6c43575ce 100644 --- a/src/libs/Metrics/types.ts +++ b/src/libs/Metrics/types.ts @@ -1,4 +1,3 @@ type CanCapturePerformanceMetrics = () => boolean; -type CanCaptureOnyxMetrics = () => boolean; -export type {CanCapturePerformanceMetrics, CanCaptureOnyxMetrics}; +export default CanCapturePerformanceMetrics; diff --git a/src/libs/MoneyRequestUtils.ts b/src/libs/MoneyRequestUtils.ts index 7009379e15de..8cf7ecb4a73d 100644 --- a/src/libs/MoneyRequestUtils.ts +++ b/src/libs/MoneyRequestUtils.ts @@ -1,7 +1,4 @@ -import type {OnyxEntry} from 'react-native-onyx'; -import type {IOUType} from '@src/CONST'; import CONST from '@src/CONST'; -import type {SelectedTabRequest} from '@src/types/onyx'; /** * Strip comma from the amount @@ -82,29 +79,4 @@ function replaceAllDigits(text: string, convertFn: (char: string) => string): st .join(''); } -/** - * Check if distance expense or not - */ -function isDistanceRequest(iouType: IOUType, selectedTab: OnyxEntry): boolean { - return (iouType === CONST.IOU.TYPE.REQUEST || iouType === CONST.IOU.TYPE.SUBMIT) && selectedTab === CONST.TAB_REQUEST.DISTANCE; -} - -/** - * Check if scan expense or not - */ -function isScanRequest(selectedTab: SelectedTabRequest): boolean { - return selectedTab === CONST.TAB_REQUEST.SCAN; -} - -export { - addLeadingZero, - isDistanceRequest, - isScanRequest, - replaceAllDigits, - stripCommaFromAmount, - stripDecimalsFromAmount, - stripSpacesFromAmount, - replaceCommasWithPeriod, - validateAmount, - validatePercentage, -}; +export {addLeadingZero, replaceAllDigits, stripCommaFromAmount, stripDecimalsFromAmount, stripSpacesFromAmount, replaceCommasWithPeriod, validateAmount, validatePercentage}; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index de1403db63f6..80befb6ccfad 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -18,7 +18,6 @@ import type { PrivateNotesNavigatorParamList, ProfileNavigatorParamList, ReferralDetailsNavigatorParamList, - ReimbursementAccountNavigatorParamList, ReportChangeWorkspaceNavigatorParamList, ReportDescriptionNavigatorParamList, ReportDetailsNavigatorParamList, @@ -647,10 +646,6 @@ const AddPersonalBankAccountModalStackNavigator = createModalStackNavigator require('../../../../pages/AddPersonalBankAccountPage').default, }); -const ReimbursementAccountModalStackNavigator = createModalStackNavigator({ - [SCREENS.REIMBURSEMENT_ACCOUNT_ROOT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default, -}); - const WalletStatementStackNavigator = createModalStackNavigator({ [SCREENS.WALLET_STATEMENT_ROOT]: () => require('../../../../pages/wallet/WalletStatementPage').default, }); @@ -675,14 +670,6 @@ const ReferralModalStackNavigator = createModalStackNavigator require('../../../../pages/ReferralDetailsPage').default, }); -const ProcessMoneyRequestHoldStackNavigator = createModalStackNavigator({ - [SCREENS.PROCESS_MONEY_REQUEST_HOLD_ROOT]: () => require('../../../../pages/ProcessMoneyRequestHoldPage').default, -}); - -const ChangePolicyEducationalStackNavigator = createModalStackNavigator({ - [SCREENS.CHANGE_POLICY_EDUCATIONAL_ROOT]: () => require('../../../../pages/ChangePolicyEducationalModal').default, -}); - const TransactionDuplicateStackNavigator = createModalStackNavigator({ [SCREENS.TRANSACTION_DUPLICATE.REVIEW]: () => require('../../../../pages/TransactionDuplicate/Review').default, [SCREENS.TRANSACTION_DUPLICATE.MERCHANT]: () => require('../../../../pages/TransactionDuplicate/ReviewMerchant').default, @@ -772,12 +759,9 @@ export { NewTaskModalStackNavigator, NewTeachersUniteNavigator, PrivateNotesModalStackNavigator, - ProcessMoneyRequestHoldStackNavigator, - ChangePolicyEducationalStackNavigator, ProfileModalStackNavigator, ReferralModalStackNavigator, TravelModalStackNavigator, - ReimbursementAccountModalStackNavigator, NewReportWorkspaceSelectionModalStackNavigator, ReportDescriptionModalStackNavigator, ReportDetailsModalStackNavigator, diff --git a/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx index 6fc61e5a7efd..ed5832dd7be6 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx @@ -38,7 +38,10 @@ function OnboardingModalNavigator() { const styles = useThemeStyles(); const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); const outerViewRef = React.useRef(null); - const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.accountID ?? CONST.DEFAULT_NUMBER_ID, canBeMissing: true}); + const [accountID] = useOnyx(ONYXKEYS.SESSION, { + selector: (session) => session?.accountID ?? CONST.DEFAULT_NUMBER_ID, + canBeMissing: true, + }); // Publish a sign_up event when we start the onboarding flow. This should track basic sign ups // as well as Google and Apple SSO. diff --git a/src/libs/NumberUtils.ts b/src/libs/NumberUtils.ts index 2dfc1e722c58..4981d8d975f5 100644 --- a/src/libs/NumberUtils.ts +++ b/src/libs/NumberUtils.ts @@ -69,13 +69,6 @@ function parseFloatAnyLocale(value: string): number { return parseFloat(value ? value.replace(',', '.') : value); } -/** - * Given an input number p and another number q, returns the largest number that's less than p and divisible by q. - */ -function roundDownToLargestMultiple(p: number, q: number) { - return Math.floor(p / q) * q; -} - /** * Rounds a number to two decimal places. * @returns the rounded value @@ -100,4 +93,4 @@ function generateNewRandomInt(old: number, min: number, max: number): number { return newNum; } -export {rand64, generateHexadecimalValue, generateRandomInt, parseFloatAnyLocale, roundDownToLargestMultiple, roundToTwoDecimalPlaces, clamp, generateNewRandomInt}; +export {rand64, generateHexadecimalValue, generateRandomInt, parseFloatAnyLocale, roundToTwoDecimalPlaces, clamp, generateNewRandomInt}; diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index bd8c336b7498..9b0b5e3e360a 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1552,13 +1552,6 @@ function isManagerMcTestReport(report: SearchOption): boolean { return report.participantsList?.some((participant) => participant.accountID === CONST.ACCOUNT_ID.MANAGER_MCTEST) ?? false; } -/** - * Helper method to check if participant email is Manager McTest - */ -function isSelectedManagerMcTest(email: string | null | undefined): boolean { - return email === CONST.EMAIL.MANAGER_MCTEST; -} - function getValidPersonalDetailOptions( options: OptionList['personalDetails'], { @@ -2355,7 +2348,6 @@ export { filterReports, getIsUserSubmittedExpenseOrScannedReceipt, getManagerMcTestParticipant, - isSelectedManagerMcTest, shouldShowLastActorDisplayName, }; diff --git a/src/libs/Performance.tsx b/src/libs/Performance.tsx index df642e9f0681..868b70b9673e 100644 --- a/src/libs/Performance.tsx +++ b/src/libs/Performance.tsx @@ -8,7 +8,7 @@ import type {PerformanceEntry, PerformanceMark, PerformanceMeasure} from 'react- import CONST from '@src/CONST'; import isE2ETestSession from './E2E/isE2ETestSession'; import getComponentDisplayName from './getComponentDisplayName'; -import * as Metrics from './Metrics'; +import canCapturePerformanceMetrics from './Metrics'; /** * Deep diff between two objects. Useful for figuring out what changed about an object from one render to the next so @@ -52,7 +52,7 @@ function measureTTI(endMark?: string): void { // We don't want an alert to show: // - on builds with performance metrics collection disabled by a feature flag // - e2e test sessions - if (!Metrics.canCapturePerformanceMetrics() || isE2ETestSession()) { + if (!canCapturePerformanceMetrics() || isE2ETestSession()) { return; } @@ -218,7 +218,7 @@ type WrappedComponentConfig = {id: string}; * A HOC that captures render timings of the Wrapped component */ function withRenderTrace({id}: WrappedComponentConfig) { - if (!Metrics.canCapturePerformanceMetrics()) { + if (!canCapturePerformanceMetrics()) { return

>(WrappedComponent: React.ComponentType

): React.ComponentType

=> WrappedComponent; } diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index cf2cd9280ad8..c27aa994af60 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -624,10 +624,6 @@ function finishCorpayBankAccountOnboarding(parameters: FinishCorpayBankAccountOn return API.write(WRITE_COMMANDS.FINISH_CORPAY_BANK_ACCOUNT_ONBOARDING, parameters, onyxData); } -function clearReimbursementAccount() { - Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, null); -} - function clearCorpayBankAccountFields() { Onyx.set(ONYXKEYS.CORPAY_FIELDS, null); } @@ -905,7 +901,6 @@ export { addPersonalBankAccount, clearOnfidoToken, clearPersonalBankAccount, - clearPlaid, setPlaidEvent, openPlaidView, connectBankAccountManually, @@ -915,7 +910,6 @@ export { handlePlaidError, setPersonalBankAccountContinueKYCOnSuccess, openPersonalBankAccountSetupView, - clearReimbursementAccount, openReimbursementAccountPage, updateBeneficialOwnersForBankAccount, updateCompanyInformationForBankAccount, diff --git a/src/libs/actions/CachedPDFPaths/index.native.ts b/src/libs/actions/CachedPDFPaths/index.native.ts index 09203995e9a1..5f3b52c94be9 100644 --- a/src/libs/actions/CachedPDFPaths/index.native.ts +++ b/src/libs/actions/CachedPDFPaths/index.native.ts @@ -1,7 +1,7 @@ import {exists, unlink} from 'react-native-fs'; import Onyx from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Add, Clear, ClearAll, ClearByKey} from './types'; +import type {Add, Clear, ClearByKey} from './types'; /* * We need to save the paths of PDF files so we can delete them later. @@ -40,8 +40,4 @@ const clearByKey: ClearByKey = (id: string) => { clear(pdfPaths[id] ?? '').then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[id]: null})); }; -const clearAll: ClearAll = () => { - Promise.all(Object.values(pdfPaths).map(clear)).then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {})); -}; - -export {add, clearByKey, clearAll}; +export {add, clearByKey}; diff --git a/src/libs/actions/CachedPDFPaths/index.ts b/src/libs/actions/CachedPDFPaths/index.ts index 3cac21bf3c25..b890e243195e 100644 --- a/src/libs/actions/CachedPDFPaths/index.ts +++ b/src/libs/actions/CachedPDFPaths/index.ts @@ -1,9 +1,7 @@ -import type {Add, ClearAll, ClearByKey} from './types'; +import type {Add, ClearByKey} from './types'; const add: Add = () => Promise.resolve(); const clearByKey: ClearByKey = () => {}; -const clearAll: ClearAll = () => {}; - -export {add, clearByKey, clearAll}; +export {add, clearByKey}; diff --git a/src/libs/actions/CachedPDFPaths/types.ts b/src/libs/actions/CachedPDFPaths/types.ts index 728759daaa98..66a579cbe852 100644 --- a/src/libs/actions/CachedPDFPaths/types.ts +++ b/src/libs/actions/CachedPDFPaths/types.ts @@ -1,6 +1,5 @@ type Add = (id: string, path: string) => Promise; type Clear = (path: string) => Promise; -type ClearAll = () => void; type ClearByKey = (id: string) => void; -export type {Add, Clear, ClearAll, ClearByKey}; +export type {Add, Clear, ClearByKey}; diff --git a/src/libs/actions/Delegate.ts b/src/libs/actions/Delegate.ts index 2f376b4eca28..98567349e039 100644 --- a/src/libs/actions/Delegate.ts +++ b/src/libs/actions/Delegate.ts @@ -529,18 +529,6 @@ function isConnectedAsDelegate() { return !!delegatedAccess?.delegate; } -function removePendingDelegate(email: string) { - if (!delegatedAccess?.delegates) { - return; - } - - Onyx.merge(ONYXKEYS.ACCOUNT, { - delegatedAccess: { - delegates: delegatedAccess.delegates.filter((delegate) => delegate.email !== email), - }, - }); -} - function updateDelegateRole(email: string, role: DelegateRole, validateCode: string) { if (!delegatedAccess?.delegates) { return; @@ -711,7 +699,6 @@ export { addDelegate, requestValidationCode, clearDelegateErrorsByField, - removePendingDelegate, restoreDelegateSession, isConnectedAsDelegate, updateDelegateRoleOptimistically, diff --git a/src/libs/actions/Device/index.ts b/src/libs/actions/Device/index.ts index 991f9ce6227b..a167a13f9507 100644 --- a/src/libs/actions/Device/index.ts +++ b/src/libs/actions/Device/index.ts @@ -62,4 +62,4 @@ function getDeviceInfoWithID(): Promise { ); }); } -export {getDeviceID, setDeviceID, getDeviceInfoWithID}; +export {setDeviceID, getDeviceInfoWithID}; diff --git a/src/libs/actions/InputFocus/index.ts b/src/libs/actions/InputFocus/index.ts index 6d8706ebdd0e..658ac2977d78 100644 --- a/src/libs/actions/InputFocus/index.ts +++ b/src/libs/actions/InputFocus/index.ts @@ -4,6 +4,5 @@ import type {Modal} from '@src/types/onyx'; function inputFocusChange(focus: boolean) {} // eslint-disable-next-line @typescript-eslint/no-unused-vars function composerFocusKeepFocusOn(ref: HTMLElement, isFocused: boolean, modal: Modal, onyxFocused: boolean) {} -const callback = (method: () => void) => method(); -export {composerFocusKeepFocusOn, inputFocusChange, callback}; +export {composerFocusKeepFocusOn, inputFocusChange}; diff --git a/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts b/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts index 8b3bf5d9af86..a9edf1bdf82e 100644 --- a/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts +++ b/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts @@ -6,7 +6,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {OnyxUpdatesFromServer, Response} from '@src/types/onyx'; import {isValidOnyxUpdateFromServer} from '@src/types/onyx/OnyxUpdatesFromServer'; // eslint-disable-next-line import/no-cycle -import * as OnyxUpdateManagerUtils from '.'; +import {validateAndApplyDeferredUpdates} from '.'; let missingOnyxUpdatesQueryPromise: Promise | undefined; let deferredUpdates: DeferredUpdatesDictionary = {}; @@ -61,10 +61,10 @@ function isEmpty() { */ function process() { if (missingOnyxUpdatesQueryPromise) { - missingOnyxUpdatesQueryPromise.finally(() => OnyxUpdateManagerUtils.validateAndApplyDeferredUpdates); + missingOnyxUpdatesQueryPromise.finally(() => validateAndApplyDeferredUpdates); } - missingOnyxUpdatesQueryPromise = OnyxUpdateManagerUtils.validateAndApplyDeferredUpdates(); + missingOnyxUpdatesQueryPromise = validateAndApplyDeferredUpdates(); } type EnqueueDeferredOnyxUpdatesOptions = { @@ -99,15 +99,6 @@ function enqueue(updates: OnyxUpdatesFromServer | DeferredUpdatesDictionary, opt } } -/** - * Adds updates to the deferred updates queue and processes them immediately - * @param updates The updates that should be applied (e.g. updates from push notifications) - */ -function enqueueAndProcess(updates: OnyxUpdatesFromServer | DeferredUpdatesDictionary, options?: EnqueueDeferredOnyxUpdatesOptions) { - enqueue(updates, options); - process(); -} - type ClearDeferredOnyxUpdatesOptions = { shouldResetGetMissingOnyxUpdatesPromise?: boolean; shouldUnpauseSequentialQueue?: boolean; @@ -130,4 +121,4 @@ function clear(options?: ClearDeferredOnyxUpdatesOptions) { } } -export {getMissingOnyxUpdatesQueryPromise, setMissingOnyxUpdatesQueryPromise, getUpdates, isEmpty, process, enqueue, enqueueAndProcess, clear}; +export {getMissingOnyxUpdatesQueryPromise, setMissingOnyxUpdatesQueryPromise, getUpdates, isEmpty, process, enqueue, clear}; diff --git a/src/libs/actions/PaymentMethods.ts b/src/libs/actions/PaymentMethods.ts index d70c0af6294e..5c7cd4f978f8 100644 --- a/src/libs/actions/PaymentMethods.ts +++ b/src/libs/actions/PaymentMethods.ts @@ -25,7 +25,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import INPUT_IDS from '@src/types/form/AddPaymentCardForm'; import type {BankAccountList, FundList} from '@src/types/onyx'; -import type {AccountData} from '@src/types/onyx/Fund'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; import type PaymentMethod from '@src/types/onyx/PaymentMethod'; import type {OnyxData} from '@src/types/onyx/Request'; @@ -536,21 +535,6 @@ function updateBillingCurrency(currency: ValueOf { - return bankAccountList; -} - function hasCreditBankAccount(): boolean { if (!bankAccountList) { return false; @@ -27,4 +23,5 @@ function hasCreditBankAccount(): boolean { }); } -export {getBankAccountList, hasCreditBankAccount}; +export default {hasCreditBankAccount}; +export {hasCreditBankAccount}; diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index d13dcb06abe8..377d92c2494a 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -15,7 +15,6 @@ import type { BeginSignInParams, DisableTwoFactorAuthParams, LogOutParams, - RequestAccountValidationLinkParams, RequestNewValidateCodeParams, RequestUnlinkValidationLinkParams, ResetSMSDeliveryFailureStatusParams, @@ -355,50 +354,6 @@ function callFunctionIfActionIsAllowed an return callback; } -/** - * Resend the validation link to the user that is validating their account - */ -function resendValidationLink(login = credentials.login) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: true, - errors: null, - message: null, - loadingForm: CONST.FORMS.RESEND_VALIDATION_FORM, - }, - }, - ]; - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: false, - message: 'resendValidationForm.linkHasBeenResent', - loadingForm: null, - }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: false, - message: null, - loadingForm: null, - }, - }, - ]; - - const params: RequestAccountValidationLinkParams = {email: login}; - - API.write(WRITE_COMMANDS.REQUEST_ACCOUNT_VALIDATION_LINK, params, {optimisticData, successData, failureData}); -} - /** * Request a new validate / magic code for user to sign in via passwordless flow */ @@ -1513,7 +1468,6 @@ export { cleanupSession, signOut, signOutAndRedirectToSignIn, - resendValidationLink, resendValidateCode, requestUnlinkValidationLink, unlinkLogin, diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index f2f55b6b77c7..d9cb8049fac7 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -85,34 +85,6 @@ Onyx.connect({ callback: (val) => (allTransactionViolations = val ?? []), }); -function createInitialWaypoints(transactionID: string) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, { - comment: { - waypoints: { - waypoint0: {}, - waypoint1: {}, - }, - }, - }); -} - -/** - * Add a stop to the transaction - */ -function addStop(transactionID: string) { - const transaction = allTransactions?.[transactionID] ?? {}; - const existingWaypoints = transaction?.comment?.waypoints ?? {}; - const newLastIndex = Object.keys(existingWaypoints).length; - - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, { - comment: { - waypoints: { - [`waypoint${newLastIndex}`]: {}, - }, - }, - }); -} - function saveWaypoint(transactionID: string, index: string, waypoint: RecentWaypoint | null, isDraft = false) { Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, { comment: { @@ -855,8 +827,6 @@ function changeTransactionsReport(transactionIDs: string[], reportID: string) { } export { - addStop, - createInitialWaypoints, saveWaypoint, removeWaypoint, getRoute, diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index c00f4c91bde0..f1e7571977b3 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -21,7 +21,6 @@ import type { UpdatePreferredEmojiSkinToneParams, UpdateStatusParams, UpdateThemeParams, - ValidateLoginParams, ValidateSecondaryLoginParams, } from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; @@ -566,38 +565,6 @@ function requestValidateCodeAction() { API.write(WRITE_COMMANDS.RESEND_VALIDATE_CODE, null, {optimisticData, successData, failureData}); } -/** - * Validates a login given an accountID and validation code - */ -function validateLogin(accountID: number, validateCode: string) { - Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, isLoading: true}); - - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: true, - }, - }, - ]; - - const finallyData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: false, - }, - }, - ]; - - const parameters: ValidateLoginParams = {accountID, validateCode}; - - API.write(WRITE_COMMANDS.VALIDATE_LOGIN, parameters, {optimisticData, finallyData}); - Navigation.navigate(ROUTES.HOME); -} - /** * Validates a secondary login / contact method */ @@ -1150,10 +1117,6 @@ function setShouldUseStagingServer(shouldUseStagingServer: boolean) { Onyx.merge(ONYXKEYS.USER, {shouldUseStagingServer}); } -function clearUserErrorMessage() { - Onyx.merge(ONYXKEYS.USER, {error: ''}); -} - function togglePlatformMute(platform: Platform, mutedPlatforms: Partial>) { const newMutedPlatforms = mutedPlatforms?.[platform] ? {...mutedPlatforms, [platform]: undefined} // Remove platform if it's muted @@ -1532,14 +1495,12 @@ export { clearContactMethodErrors, clearContactMethod, addNewContactMethod, - validateLogin, validateSecondaryLogin, isBlockedFromConcierge, subscribeToUserEvents, updatePreferredSkinTone, setShouldUseStagingServer, togglePlatformMute, - clearUserErrorMessage, joinScreenShare, clearScreenShareRequest, generateStatementPDF, diff --git a/src/libs/actions/Wallet.ts b/src/libs/actions/Wallet.ts index e0a19056e893..de240fbc6837 100644 --- a/src/libs/actions/Wallet.ts +++ b/src/libs/actions/Wallet.ts @@ -9,9 +9,7 @@ import Log from '@libs/Log'; import type CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {WalletAdditionalQuestionDetails} from '@src/types/onyx'; -import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import pkg from '../../../package.json'; -import {clearErrors} from './FormActions'; type WalletQuestionAnswer = { question: string; @@ -53,11 +51,6 @@ function setAdditionalDetailsQuestions(questions: WalletAdditionalQuestionDetail Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {questions, idNumber}); } -function setAdditionalDetailsErrors(errorFields: OnyxCommon.ErrorFields) { - Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {errorFields: null}); - Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {errorFields}); -} - /** * Save the source that triggered the KYC wall and optionally the chat report ID associated with the IOU */ @@ -257,23 +250,6 @@ function resetWalletAdditionalDetailsDraft() { Onyx.set(ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS_DRAFT, null); } -/** - * Clear the error of specific card - * @param cardID The card id of the card that you want to clear the errors. - */ -function clearPhysicalCardError(cardID?: string) { - if (!cardID) { - return; - } - - clearErrors(ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM); - Onyx.merge(ONYXKEYS.CARD_LIST, { - [cardID]: { - errors: null, - }, - }); -} - function issuerEncryptPayloadCallback(nonce: string, nonceSignature: string, certificates: string[]): Promise { // eslint-disable-next-line rulesdir/no-api-side-effects-method, rulesdir/no-api-in-views return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.CREATE_DIGITAL_WALLET, { @@ -301,7 +277,6 @@ export { openOnfidoFlow, openInitialSettingsPage, openEnablePaymentsPage, - setAdditionalDetailsErrors, setAdditionalDetailsQuestions, updateCurrentStep, answerQuestionsForWallet, @@ -310,6 +285,5 @@ export { acceptWalletTerms, setKYCWallSource, resetWalletAdditionalDetailsDraft, - clearPhysicalCardError, issuerEncryptPayloadCallback, }; diff --git a/src/libs/actions/Welcome/index.ts b/src/libs/actions/Welcome/index.ts index f2bf52d5b5b2..4ba55759840f 100644 --- a/src/libs/actions/Welcome/index.ts +++ b/src/libs/actions/Welcome/index.ts @@ -96,10 +96,6 @@ function checkOnboardingDataReady() { resolveOnboardingFlowStatus(); } -function setOnboardingCustomChoices(value: OnboardingPurpose[]) { - Onyx.set(ONYXKEYS.ONBOARDING_CUSTOM_CHOICES, value ?? []); -} - function setOnboardingPurposeSelected(value: OnboardingPurpose) { Onyx.set(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, value ?? null); } @@ -244,7 +240,6 @@ export { onServerDataReady, isOnboardingFlowCompleted, dismissProductTraining, - setOnboardingCustomChoices, setOnboardingPurposeSelected, updateOnboardingLastVisitedPath, resetAllChecks, diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index c0215e91838a..a2cd42b258bd 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -1,30 +1,19 @@ import {differenceInMinutes, isValid, parseISO} from 'date-fns'; -import isObject from 'lodash/isObject'; import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; -import type { - RemovePolicyConnectionParams, - SyncPolicyToQuickbooksDesktopParams, - UpdateManyPolicyConnectionConfigurationsParams, - UpdatePolicyConnectionConfigParams, -} from '@libs/API/parameters'; +import type {RemovePolicyConnectionParams, SyncPolicyToQuickbooksDesktopParams, UpdateManyPolicyConnectionConfigurationsParams} from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import type {ConnectionName, Connections, PolicyConnectionName, PolicyConnectionSyncProgress} from '@src/types/onyx/Policy'; import type Policy from '@src/types/onyx/Policy'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; type ConnectionNameExceptNetSuite = Exclude; -type Nullable = { - [P in keyof T]: T[P] | null; -}; - function removePolicyConnection(policyID: string, connectionName: PolicyConnectionName) { const optimisticData: OnyxUpdate[] = [ { @@ -89,105 +78,6 @@ function removePolicyConnection(policyID: string, connectionName: PolicyConnecti API.write(WRITE_COMMANDS.REMOVE_POLICY_CONNECTION, parameters, {optimisticData, successData, failureData}); } -function createPendingFields( - settingName: TSettingName, - settingValue: Partial, - pendingValue: OnyxCommon.PendingAction, -) { - if (!isObject(settingValue)) { - return {[settingName]: pendingValue}; - } - - return Object.keys(settingValue).reduce>((acc, setting) => { - acc[setting] = pendingValue; - return acc; - }, {}); -} - -function createErrorFields( - settingName: TSettingName, - settingValue: Partial, - errorValue: OnyxCommon.Errors | null, -) { - if (!isObject(settingValue)) { - return {[settingName]: errorValue}; - } - - return Object.keys(settingValue).reduce((acc, setting) => { - acc[setting] = errorValue; - return acc; - }, {}); -} - -function updatePolicyConnectionConfig( - policyID: string, - connectionName: TConnectionName, - settingName: TSettingName, - settingValue: Partial, - oldSettingValue?: Nullable>, -) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - connections: { - [connectionName]: { - config: { - [settingName]: settingValue ?? null, - pendingFields: createPendingFields(settingName, settingValue, CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE), - errorFields: createErrorFields(settingName, settingValue, null), - }, - }, - }, - }, - }, - ]; - - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - connections: { - [connectionName]: { - config: { - [settingName]: oldSettingValue ?? null, - pendingFields: createPendingFields(settingName, settingValue, null), - errorFields: createErrorFields(settingName, settingValue, ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')), - }, - }, - }, - }, - }, - ]; - - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - connections: { - [connectionName]: { - config: { - pendingFields: createPendingFields(settingName, settingValue, null), - errorFields: createErrorFields(settingName, settingValue, null), - }, - }, - }, - }, - }, - ]; - - const parameters: UpdatePolicyConnectionConfigParams = { - policyID, - connectionName, - settingName: String(settingName), - settingValue: JSON.stringify(settingValue), - idempotencyKey: String(settingName), - }; - API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData}); -} /** * This method returns read command and stage in progres for a given accounting integration. * @@ -440,7 +330,6 @@ function isConnectionInProgress(connectionSyncProgress: OnyxEntry session?.accountID, canBeMissing: true}); + const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, { + selector: (session) => session?.accountID, + canBeMissing: true, + }); // When we create a new workspace, the policy prop will be empty on the first render. Therefore, we have to use policyDraft until policy has been set in Onyx. const policy = policyDraft?.id ? policyDraft : policyProp; @@ -76,7 +79,10 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa // We need this to update translation for deleting a workspace when it has third party card feeds or expensify card assigned. const workspaceAccountID = policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID; const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, {canBeMissing: true}); - const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, {selector: filterInactiveCards, canBeMissing: true}); + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, { + selector: filterInactiveCards, + canBeMissing: true, + }); const hasCardFeedOrExpensifyCard = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing !isEmptyObject(cardFeeds) || !isEmptyObject(cardsList) || ((policy?.areExpensifyCardsEnabled || policy?.areCompanyCardsEnabled) && policy?.workspaceAccountID); @@ -166,7 +172,7 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); - const {setIsDeletingPaidWorkspace, isLoadingBill} = usePayAndDowngrade(setIsDeleteModalOpen); + const {setIsDeletingPaidWorkspace, isLoadingBill}: {setIsDeletingPaidWorkspace: (value: boolean) => void; isLoadingBill: boolean | undefined} = usePayAndDowngrade(setIsDeleteModalOpen); const confirmDeleteAndHideModal = useCallback(() => { if (!policy?.id || !policyName) { diff --git a/src/pages/workspace/WorkspacesListPage.tsx b/src/pages/workspace/WorkspacesListPage.tsx index 01fa5d11aa8a..65edcb67d7d8 100755 --- a/src/pages/workspace/WorkspacesListPage.tsx +++ b/src/pages/workspace/WorkspacesListPage.tsx @@ -136,14 +136,13 @@ function WorkspacesListPage() { const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true}); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); - const shouldShowLoadingIndicator = isLoadingApp && !isOffline; const route = useRoute>(); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); const [policyIDToDelete, setPolicyIDToDelete] = useState(); const [policyNameToDelete, setPolicyNameToDelete] = useState(); - const {setIsDeletingPaidWorkspace, isLoadingBill} = usePayAndDowngrade(setIsDeleteModalOpen); + const {setIsDeletingPaidWorkspace, isLoadingBill}: {setIsDeletingPaidWorkspace: (value: boolean) => void; isLoadingBill: boolean | undefined} = usePayAndDowngrade(setIsDeleteModalOpen); const [loadingSpinnerIconIndex, setLoadingSpinnerIconIndex] = useState(null); @@ -152,7 +151,10 @@ function WorkspacesListPage() { // We need this to update translation for deleting a workspace when it has third party card feeds or expensify card assigned. const workspaceAccountID = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyIDToDelete}`]?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID; const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, {canBeMissing: true}); - const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, {selector: filterInactiveCards, canBeMissing: true}); + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, { + selector: filterInactiveCards, + canBeMissing: true, + }); const policyToDelete = getPolicy(policyIDToDelete); const hasCardFeedOrExpensifyCard = !isEmptyObject(cardFeeds) || @@ -181,7 +183,7 @@ function WorkspacesListPage() { } }; - const shouldCalculateBillNewDot = shouldCalculateBillNewDotFn(); + const shouldCalculateBillNewDot: boolean = shouldCalculateBillNewDotFn(); const resetLoadingSpinnerIconIndex = useCallback(() => { setLoadingSpinnerIconIndex(null); diff --git a/src/setup/platformSetup/index.native.ts b/src/setup/platformSetup/index.native.ts index ded98285aa3e..62e7a52e1a68 100644 --- a/src/setup/platformSetup/index.native.ts +++ b/src/setup/platformSetup/index.native.ts @@ -1,5 +1,5 @@ import crashlytics from '@react-native-firebase/crashlytics'; -import * as Metrics from '@libs/Metrics'; +import canCapturePerformanceMetrics from '@libs/Metrics'; import Performance from '@libs/Performance'; import CONFIG from '@src/CONFIG'; @@ -11,7 +11,7 @@ export default function () { crashlytics().setCrashlyticsCollectionEnabled(false); } - if (Metrics.canCapturePerformanceMetrics()) { + if (canCapturePerformanceMetrics()) { Performance.enableMonitoring(); } }