): 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();
}
}