From 75c271da01d793453dc8520d130a2d93d5ad222a Mon Sep 17 00:00:00 2001 From: Olgierd Date: Thu, 18 Dec 2025 01:03:07 +0100 Subject: [PATCH 01/10] Replace default updateOnyx union type with specific types in type annotations in variable declarations --- src/libs/PersonalDetailsUtils.ts | 4 +- src/libs/PolicyDistanceRatesUtils.ts | 6 +- src/libs/ReportTitleUtils.ts | 4 +- src/libs/actions/App.ts | 2 +- src/libs/actions/Chronos.ts | 6 +- src/libs/actions/CompanyCards.ts | 24 +++---- src/libs/actions/Delegate.ts | 30 ++++---- src/libs/actions/Domain.ts | 38 +++++------ src/libs/actions/ExitSurvey.ts | 2 +- src/libs/actions/MergeAccounts.ts | 12 ++-- src/libs/actions/PaymentMethods.ts | 34 +++++----- src/libs/actions/PersonalDetails.ts | 24 +++---- src/libs/actions/Policy/Category.ts | 6 +- src/libs/actions/Policy/DistanceRate.ts | 18 ++--- src/libs/actions/Policy/Member.ts | 18 ++--- src/libs/actions/Policy/Plan.ts | 6 +- src/libs/actions/ReportLayout.ts | 4 +- src/libs/actions/RequestConflictUtils.ts | 2 +- src/libs/actions/ScheduleCall.ts | 6 +- src/libs/actions/Search.ts | 32 ++++----- src/libs/actions/Session/index.ts | 50 +++++++------- src/libs/actions/SidePanel.ts | 4 +- src/libs/actions/Subscription.ts | 18 ++--- src/libs/actions/Task.ts | 22 +++--- src/libs/actions/TeachersUnite.ts | 8 +-- src/libs/actions/User.ts | 68 +++++++++---------- src/libs/actions/Wallet.ts | 24 +++---- src/libs/actions/Welcome/index.ts | 4 +- src/libs/actions/Workflow.ts | 18 ++--- .../actions/connections/NetSuiteCommands.ts | 20 +++--- .../actions/connections/QuickbooksDesktop.ts | 24 +++---- .../actions/connections/QuickbooksOnline.ts | 12 ++-- src/libs/actions/connections/SageIntacct.ts | 48 ++++++------- src/libs/actions/connections/Xero.ts | 18 ++--- src/libs/actions/connections/index.ts | 14 ++-- src/libs/getFirstAlphaNumericCharacter.ts | 10 ++- src/utils/createDummySharedValue.ts | 6 +- 37 files changed, 322 insertions(+), 324 deletions(-) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 0b53af0357806..51c123c5e6e1b 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -236,7 +236,7 @@ function getPersonalDetailsOnyxDataForOptimisticUsers( personalDetailsCleanup[accountID] = null; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -244,7 +244,7 @@ function getPersonalDetailsOnyxDataForOptimisticUsers( }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, diff --git a/src/libs/PolicyDistanceRatesUtils.ts b/src/libs/PolicyDistanceRatesUtils.ts index 1791e7f1da1b7..b4f43be51b9b3 100644 --- a/src/libs/PolicyDistanceRatesUtils.ts +++ b/src/libs/PolicyDistanceRatesUtils.ts @@ -87,7 +87,7 @@ function buildOnyxDataForPolicyDistanceRateUpdates(policyID: string, customUnit: } } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -101,7 +101,7 @@ function buildOnyxDataForPolicyDistanceRateUpdates(policyID: string, customUnit: }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -115,7 +115,7 @@ function buildOnyxDataForPolicyDistanceRateUpdates(policyID: string, customUnit: }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/ReportTitleUtils.ts b/src/libs/ReportTitleUtils.ts index 006e49049c933..fb7482d684a33 100644 --- a/src/libs/ReportTitleUtils.ts +++ b/src/libs/ReportTitleUtils.ts @@ -69,7 +69,7 @@ function updateTitleFieldToMatchPolicy(reportID: string, policy?: Policy): OnyxU } // Create the update to set/update the title field in rNVP - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, @@ -94,7 +94,7 @@ function removeTitleFieldFromReport(reportID: string): OnyxUpdate[] { return []; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index 8c693b1df7c50..e0b6eefc12f73 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -181,7 +181,7 @@ function setLocale(locale: Locale, currentPreferredLocale: Locale | undefined) { } // Optimistically change preferred locale - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PREFERRED_LOCALE, diff --git a/src/libs/actions/Chronos.ts b/src/libs/actions/Chronos.ts index 5a54c2ee93687..1c26a1f79d177 100644 --- a/src/libs/actions/Chronos.ts +++ b/src/libs/actions/Chronos.ts @@ -8,7 +8,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {ChronosOOOEvent} from '@src/types/onyx/OriginalMessage'; const removeEvent = (reportID: string | undefined, reportActionID: string, eventID: string, events: ChronosOOOEvent[]) => { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -23,7 +23,7 @@ const removeEvent = (reportID: string | undefined, reportActionID: string, event }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -35,7 +35,7 @@ const removeEvent = (reportID: string | undefined, reportActionID: string, event }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, diff --git a/src/libs/actions/CompanyCards.ts b/src/libs/actions/CompanyCards.ts index 676c0abd66bb2..913208b65e420 100644 --- a/src/libs/actions/CompanyCards.ts +++ b/src/libs/actions/CompanyCards.ts @@ -89,7 +89,7 @@ function addNewCompanyCardsFeed( const feedType = CardUtils.getFeedType(cardFeed, cardFeeds); const newSelectedFeed = getCompanyCardFeedWithDomainID(feedType as CompanyCardFeed, workspaceAccountID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.LAST_SELECTED_FEED}${policyID}`, @@ -112,7 +112,7 @@ function addNewCompanyCardsFeed( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.LAST_SELECTED_FEED}${policyID}`, @@ -132,7 +132,7 @@ function addNewCompanyCardsFeed( }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, @@ -733,7 +733,7 @@ function clearCompanyCardErrorField(domainOrWorkspaceAccountID: number, cardID: function openPolicyCompanyCardsPage(policyID: string, domainOrWorkspaceAccountID: number) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -743,7 +743,7 @@ function openPolicyCompanyCardsPage(policyID: string, domainOrWorkspaceAccountID }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -753,7 +753,7 @@ function openPolicyCompanyCardsPage(policyID: string, domainOrWorkspaceAccountID }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -787,7 +787,7 @@ function openAssignFeedCardPage(policyID: string, feed: CompanyCardFeed, domainO feed, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -797,7 +797,7 @@ function openAssignFeedCardPage(policyID: string, feed: CompanyCardFeed, domainO }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -807,7 +807,7 @@ function openAssignFeedCardPage(policyID: string, feed: CompanyCardFeed, domainO }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -842,7 +842,7 @@ function setFeedStatementPeriodEndDay( ) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainAccountID}`, @@ -864,7 +864,7 @@ function setFeedStatementPeriodEndDay( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainAccountID}`, @@ -882,7 +882,7 @@ function setFeedStatementPeriodEndDay( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainAccountID}`, diff --git a/src/libs/actions/Delegate.ts b/src/libs/actions/Delegate.ts index 563378dd04f2a..76bf304b06dd1 100644 --- a/src/libs/actions/Delegate.ts +++ b/src/libs/actions/Delegate.ts @@ -126,7 +126,7 @@ function connect({email, delegatedAccess, credentials, session, activePolicyID, const previousAccountID = getCurrentUserAccountID(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -142,7 +142,7 @@ function connect({email, delegatedAccess, credentials, session, activePolicyID, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -158,7 +158,7 @@ function connect({email, delegatedAccess, credentials, session, activePolicyID, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -222,7 +222,7 @@ function connect({email, delegatedAccess, credentials, session, activePolicyID, } function disconnect({stashedCredentials, stashedSession}: DisconnectParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -234,7 +234,7 @@ function disconnect({stashedCredentials, stashedSession}: DisconnectParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -246,7 +246,7 @@ function disconnect({stashedCredentials, stashedSession}: DisconnectParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -413,7 +413,7 @@ function addDelegate({email, role, validateCode, delegatedAccess}: AddDelegatePa ]; }; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -457,7 +457,7 @@ function addDelegate({email, role, validateCode, delegatedAccess}: AddDelegatePa ]; }; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -489,7 +489,7 @@ function removeDelegate({email, delegatedAccess}: RemoveDelegateParams) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -514,7 +514,7 @@ function removeDelegate({email, delegatedAccess}: RemoveDelegateParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -526,7 +526,7 @@ function removeDelegate({email, delegatedAccess}: RemoveDelegateParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -581,7 +581,7 @@ function updateDelegateRole({email, role, validateCode, delegatedAccess}: Update return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -608,7 +608,7 @@ function updateDelegateRole({email, role, validateCode, delegatedAccess}: Update }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -636,7 +636,7 @@ function updateDelegateRole({email, role, validateCode, delegatedAccess}: Update }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -668,7 +668,7 @@ function clearDelegateRolePendingAction({email, delegatedAccess}: ClearDelegateR return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, diff --git a/src/libs/actions/Domain.ts b/src/libs/actions/Domain.ts index 4c2d982dd090d..d6afcd39726e7 100644 --- a/src/libs/actions/Domain.ts +++ b/src/libs/actions/Domain.ts @@ -12,14 +12,14 @@ import {ScimTokenState} from './ScimToken/ScimTokenUtils'; * Fetches a validation code that the user is supposed to put in the domain's DNS records to verify it */ function getDomainValidationCode(accountID: number, domainName: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, value: {isValidateCodeLoading: true, validateCodeError: null}, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -27,7 +27,7 @@ function getDomainValidationCode(accountID: number, domainName: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -45,7 +45,7 @@ function getDomainValidationCode(accountID: number, domainName: string) { * Checks if the validation code is present in the domain's DNS records to mark the domain as validated and the user as a verified admin */ function validateDomain(accountID: number, domainName: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -53,7 +53,7 @@ function validateDomain(accountID: number, domainName: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -61,7 +61,7 @@ function validateDomain(accountID: number, domainName: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -95,7 +95,7 @@ function openDomainInitialPage(domainName: string) { * Sets SAML identity provider metadata for a domain */ function setSamlIdentity(accountID: number, domainName: string, metaIdentity: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -112,7 +112,7 @@ function setSamlIdentity(accountID: number, domainName: string, metaIdentity: st }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -129,7 +129,7 @@ function setSamlIdentity(accountID: number, domainName: string, metaIdentity: st * Fetches the domain's SAML metadata */ function getSamlSettings(accountID: number, domainName: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -140,7 +140,7 @@ function getSamlSettings(accountID: number, domainName: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -149,7 +149,7 @@ function getSamlSettings(accountID: number, domainName: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -167,7 +167,7 @@ function getSamlSettings(accountID: number, domainName: string) { * Sets whether logging in via SAML is enabled for the domain */ function setSamlEnabled({enabled, accountID, domainName}: {enabled: boolean; accountID: number; domainName: string}) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${accountID}`, @@ -186,14 +186,14 @@ function setSamlEnabled({enabled, accountID, domainName}: {enabled: boolean; acc }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, value: {isSamlEnabledLoading: null}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -233,7 +233,7 @@ function setSamlRequired({required, accountID, domainName, metaIdentity}: {requi return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${accountID}`, @@ -252,14 +252,14 @@ function setSamlRequired({required, accountID, domainName, metaIdentity}: {requi }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, value: {isSamlRequiredLoading: null}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -318,14 +318,14 @@ async function getScimToken(domainName: string): Promise { /** Sends request for claiming a domain */ function createDomain(domainName: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CREATE_DOMAIN_FORM, value: {hasCreationSucceeded: null, isLoading: true}, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CREATE_DOMAIN_FORM, diff --git a/src/libs/actions/ExitSurvey.ts b/src/libs/actions/ExitSurvey.ts index b2c14c33681ff..dfcb0f3ed7fa0 100644 --- a/src/libs/actions/ExitSurvey.ts +++ b/src/libs/actions/ExitSurvey.ts @@ -13,7 +13,7 @@ function saveResponse(response: string) { * Save the user's response to the mandatory exit survey in the back-end. */ function switchToOldDot(exitSurveyResponse: string | undefined) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.FORMS.EXIT_SURVEY_RESPONSE_FORM, diff --git a/src/libs/actions/MergeAccounts.ts b/src/libs/actions/MergeAccounts.ts index f7a7ca58bb8ed..7222623262d6e 100644 --- a/src/libs/actions/MergeAccounts.ts +++ b/src/libs/actions/MergeAccounts.ts @@ -13,7 +13,7 @@ function requestValidationCodeForAccountMerge(email: string, validateCodeResent const parsedPhoneNumber = parsePhoneNumber(appendCountryCode(Str.removeSMSDomain(email), countryCode)); const normalizedEmail = parsedPhoneNumber.possible && parsedPhoneNumber.number?.e164 ? parsedPhoneNumber.number.e164 : email.toLowerCase(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -28,7 +28,7 @@ function requestValidationCodeForAccountMerge(email: string, validateCodeResent }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -43,7 +43,7 @@ function requestValidationCodeForAccountMerge(email: string, validateCodeResent }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -76,7 +76,7 @@ function clearGetValidateCodeForAccountMerge() { } function mergeWithValidateCode(email: string, validateCode: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -90,7 +90,7 @@ function mergeWithValidateCode(email: string, validateCode: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -104,7 +104,7 @@ function mergeWithValidateCode(email: string, validateCode: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, diff --git a/src/libs/actions/PaymentMethods.ts b/src/libs/actions/PaymentMethods.ts index 9045fbe9b890f..4924ebb1ad9a6 100644 --- a/src/libs/actions/PaymentMethods.ts +++ b/src/libs/actions/PaymentMethods.ts @@ -43,21 +43,21 @@ function continueSetup(kycWallRef: RefObject, fallbackRoute?: } function getPaymentMethods(includePartiallySetupBankAccounts?: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_PAYMENT_METHODS, value: true, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_PAYMENT_METHODS, value: false, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_PAYMENT_METHODS, @@ -169,7 +169,7 @@ function addPaymentCard(accountID: number, params: PaymentCardParams) { isP2PDebitCard: true, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -177,7 +177,7 @@ function addPaymentCard(accountID: number, params: PaymentCardParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -185,7 +185,7 @@ function addPaymentCard(accountID: number, params: PaymentCardParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -233,7 +233,7 @@ function addSubscriptionPaymentCard( shouldClaimEarlyDiscountOffer: true, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -241,7 +241,7 @@ function addSubscriptionPaymentCard( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -249,7 +249,7 @@ function addSubscriptionPaymentCard( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -340,7 +340,7 @@ function transferWalletBalance(paymentMethod: PaymentMethod) { [paymentMethodIDKey]: paymentMethod.methodID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.WALLET_TRANSFER, @@ -351,7 +351,7 @@ function transferWalletBalance(paymentMethod: PaymentMethod) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.WALLET_TRANSFER, @@ -363,7 +363,7 @@ function transferWalletBalance(paymentMethod: PaymentMethod) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.WALLET_TRANSFER, @@ -491,7 +491,7 @@ function updateBillingCurrency(currency: ValueOf> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CHANGE_BILLING_CURRENCY_FORM, @@ -502,7 +502,7 @@ function updateBillingCurrency(currency: ValueOf> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CHANGE_BILLING_CURRENCY_FORM, @@ -512,7 +512,7 @@ function updateBillingCurrency(currency: ValueOf> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CHANGE_BILLING_CURRENCY_FORM, @@ -539,7 +539,7 @@ function setInvoicingTransferBankAccount(bankAccountID: number, policyID: string policyID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -553,7 +553,7 @@ function setInvoicingTransferBankAccount(bankAccountID: number, policyID: string }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/PersonalDetails.ts b/src/libs/actions/PersonalDetails.ts index ebbae4b5a9244..eea7c4160fec7 100644 --- a/src/libs/actions/PersonalDetails.ts +++ b/src/libs/actions/PersonalDetails.ts @@ -115,7 +115,7 @@ function updateLegalName( currentUserPersonalDetail: Pick, ) { const parameters: UpdateLegalNameParams = {legalFirstName, legalLastName}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS, @@ -316,7 +316,7 @@ function updateSelectedTimezone(selectedTimezone: SelectedTimezone, currentUserA * but the profile page will use other info (e.g. contact methods and pronouns) if they are already available in Onyx */ function openPublicProfilePage(accountID: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_METADATA, @@ -328,7 +328,7 @@ function openPublicProfilePage(accountID: number) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_METADATA, @@ -340,7 +340,7 @@ function openPublicProfilePage(accountID: number) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_METADATA, @@ -377,7 +377,7 @@ function updateAvatar( return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -398,7 +398,7 @@ function updateAvatar( }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -411,7 +411,7 @@ function updateAvatar( }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -444,7 +444,7 @@ function deleteAvatar(currentUserPersonalDetails: Pick> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -456,7 +456,7 @@ function deleteAvatar(currentUserPersonalDetails: Pick> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -560,7 +560,7 @@ function setPersonalDetailsAndRevealExpensifyCard( cardID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS, @@ -575,7 +575,7 @@ function setPersonalDetailsAndRevealExpensifyCard( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS, @@ -595,7 +595,7 @@ function setPersonalDetailsAndRevealExpensifyCard( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS, diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index 12012ea4fee79..eeb56257293af 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -1181,7 +1181,7 @@ function enablePolicyCategories(policyData: PolicyData, enabled: boolean, should } function setPolicyCustomUnitDefaultCategory(policyID: string, customUnitID: string, oldCategory: string | undefined, category: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1196,7 +1196,7 @@ function setPolicyCustomUnitDefaultCategory(policyID: string, customUnitID: stri }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1210,7 +1210,7 @@ function setPolicyCustomUnitDefaultCategory(policyID: string, customUnitID: stri }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/Policy/DistanceRate.ts b/src/libs/actions/Policy/DistanceRate.ts index 11a705e20f2ba..e210f90849620 100644 --- a/src/libs/actions/Policy/DistanceRate.ts +++ b/src/libs/actions/Policy/DistanceRate.ts @@ -127,7 +127,7 @@ function enablePolicyDistanceRates(policyID: string, enabled: boolean, customUni } function createPolicyDistanceRate(policyID: string, customUnitID: string, customUnitRate: Rate) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -146,7 +146,7 @@ function createPolicyDistanceRate(policyID: string, customUnitID: string, custom }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -164,7 +164,7 @@ function createPolicyDistanceRate(policyID: string, customUnitID: string, custom }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -242,7 +242,7 @@ function clearPolicyDistanceRateErrorFields(policyID: string, customUnitID: stri } function setPolicyDistanceRatesUnit(policyID: string, currentCustomUnit: CustomUnit, newCustomUnit: CustomUnit) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -257,7 +257,7 @@ function setPolicyDistanceRatesUnit(policyID: string, currentCustomUnit: CustomU }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -271,7 +271,7 @@ function setPolicyDistanceRatesUnit(policyID: string, currentCustomUnit: CustomU }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -339,7 +339,7 @@ function setPolicyDistanceRatesEnabled(policyID: string, customUnit: CustomUnit, } } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -353,7 +353,7 @@ function setPolicyDistanceRatesEnabled(policyID: string, customUnit: CustomUnit, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -367,7 +367,7 @@ function setPolicyDistanceRatesEnabled(policyID: string, customUnit: CustomUnit, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/Policy/Member.ts b/src/libs/actions/Policy/Member.ts index f783083a6ee73..b61734eaf53f1 100644 --- a/src/libs/actions/Policy/Member.ts +++ b/src/libs/actions/Policy/Member.ts @@ -778,7 +778,7 @@ function requestWorkspaceOwnerChange(policyID: string | undefined, currentUserAc }); } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -791,7 +791,7 @@ function requestWorkspaceOwnerChange(policyID: string | undefined, currentUserAc }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -805,7 +805,7 @@ function requestWorkspaceOwnerChange(policyID: string | undefined, currentUserAc }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1160,7 +1160,7 @@ function acceptJoinRequest(reportID: string | undefined, reportAction: OnyxEntry } const choice = CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1173,7 +1173,7 @@ function acceptJoinRequest(reportID: string | undefined, reportAction: OnyxEntry }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1186,7 +1186,7 @@ function acceptJoinRequest(reportID: string | undefined, reportAction: OnyxEntry }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1222,7 +1222,7 @@ function declineJoinRequest(reportID: string | undefined, reportAction: OnyxEntr return; } const choice = CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.DECLINE; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1235,7 +1235,7 @@ function declineJoinRequest(reportID: string | undefined, reportAction: OnyxEntr }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1248,7 +1248,7 @@ function declineJoinRequest(reportID: string | undefined, reportAction: OnyxEntr }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, diff --git a/src/libs/actions/Policy/Plan.ts b/src/libs/actions/Policy/Plan.ts index a30e8bb677040..c5f8c922d0288 100644 --- a/src/libs/actions/Policy/Plan.ts +++ b/src/libs/actions/Policy/Plan.ts @@ -12,7 +12,7 @@ function OpenWorkspacePlanPage(policyID: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -22,7 +22,7 @@ function OpenWorkspacePlanPage(policyID: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -32,7 +32,7 @@ function OpenWorkspacePlanPage(policyID: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/ReportLayout.ts b/src/libs/actions/ReportLayout.ts index 9754787baec86..4ad7b6621cf5e 100644 --- a/src/libs/actions/ReportLayout.ts +++ b/src/libs/actions/ReportLayout.ts @@ -10,7 +10,7 @@ import type {ReportLayoutGroupBy} from '@src/types/onyx'; * Set the user's report layout group-by preference */ function setReportLayoutGroupBy(groupBy: ReportLayoutGroupBy, previousValue?: string | null) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_REPORT_LAYOUT_GROUP_BY, @@ -18,7 +18,7 @@ function setReportLayoutGroupBy(groupBy: ReportLayoutGroupBy, previousValue?: st }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_REPORT_LAYOUT_GROUP_BY, diff --git a/src/libs/actions/RequestConflictUtils.ts b/src/libs/actions/RequestConflictUtils.ts index 7cf4c2021d55a..76cd10a78ee63 100644 --- a/src/libs/actions/RequestConflictUtils.ts +++ b/src/libs/actions/RequestConflictUtils.ts @@ -137,7 +137,7 @@ function resolveCommentDeletionConflicts(persistedRequests: OnyxRequest[], repor if (addCommentFound) { // The new message performs some changes in Onyx, so we need to rollback those changes. - const rollbackData: OnyxUpdate[] = [ + const rollbackData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, diff --git a/src/libs/actions/ScheduleCall.ts b/src/libs/actions/ScheduleCall.ts index d33e57ceeb548..9d915785a03d4 100644 --- a/src/libs/actions/ScheduleCall.ts +++ b/src/libs/actions/ScheduleCall.ts @@ -15,7 +15,7 @@ function getGuideCallAvailabilitySchedule(reportID: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, @@ -28,7 +28,7 @@ function getGuideCallAvailabilitySchedule(reportID: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, @@ -41,7 +41,7 @@ function getGuideCallAvailabilitySchedule(reportID: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 5fcd61753af9f..44735b53ad44a 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -217,7 +217,7 @@ function getOnyxLoadingData( isOffline?: boolean, isSearchAPI = false, ): {optimisticData: OnyxUpdate[]; finallyData: OnyxUpdate[]; failureData: OnyxUpdate[]} { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, @@ -237,7 +237,7 @@ function getOnyxLoadingData( }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, @@ -249,7 +249,7 @@ function getOnyxLoadingData( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -446,7 +446,7 @@ function holdMoneyRequestOnSearch(hash: number, transactionIDList: string[], com } function submitMoneyRequestOnSearch(hash: number, reportList: Report[], policy: Policy[], currentSearchKey?: SearchKey) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -454,7 +454,7 @@ function submitMoneyRequestOnSearch(hash: number, reportList: Report[], policy: }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -473,7 +473,7 @@ function submitMoneyRequestOnSearch(hash: number, reportList: Report[], policy: }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -501,7 +501,7 @@ function submitMoneyRequestOnSearch(hash: number, reportList: Report[], policy: } function approveMoneyRequestOnSearch(hash: number, reportIDList: string[], currentSearchKey?: SearchKey) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -509,7 +509,7 @@ function approveMoneyRequestOnSearch(hash: number, reportIDList: string[], curre }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -529,7 +529,7 @@ function approveMoneyRequestOnSearch(hash: number, reportIDList: string[], curre }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -553,7 +553,7 @@ function exportToIntegrationOnSearch(hash: number, reportID: string, connectionN const successAction: OptimisticExportIntegrationAction = {...optimisticAction, pendingAction: null}; const optimisticReportActionID = optimisticAction.reportActionID; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -568,7 +568,7 @@ function exportToIntegrationOnSearch(hash: number, reportID: string, connectionN }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -596,7 +596,7 @@ function exportToIntegrationOnSearch(hash: number, reportID: string, connectionN }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -629,7 +629,7 @@ function exportToIntegrationOnSearch(hash: number, reportID: string, connectionN } function payMoneyRequestOnSearch(hash: number, paymentData: PaymentData[], currentSearchKey?: SearchKey) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -637,7 +637,7 @@ function payMoneyRequestOnSearch(hash: number, paymentData: PaymentData[], curre }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -656,7 +656,7 @@ function payMoneyRequestOnSearch(hash: number, paymentData: PaymentData[], curre }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -709,7 +709,7 @@ function deleteMoneyRequestOnSearch(hash: number, transactionIDList: string[]) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index 9b5e0618ee0ea..b71b9c86a79b7 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -148,7 +148,7 @@ function setSupportAuthToken(supportAuthToken: string, email: string, accountID: } function getShortLivedLoginParams(isSupportAuthTokenUsed = false, isSAML = false) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -170,7 +170,7 @@ function getShortLivedLoginParams(isSupportAuthTokenUsed = false, isSAML = false ]; // Subsequently, we revert it back to the default value of 'signedInWithShortLivedAuthToken' in 'finallyData' to ensure the user is logged out on refresh - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -435,7 +435,7 @@ function callFunctionIfActionIsAllowed an * Request a new validate / magic code for user to sign in via passwordless flow */ function resendValidateCode(login = credentials.login) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -445,7 +445,7 @@ function resendValidateCode(login = credentials.login) { }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -545,7 +545,7 @@ function buildOnyxDataToCleanUpAnonymousUser() { * */ function signUpUser(preferredLocale: Locale | undefined) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -569,7 +569,7 @@ function signUpUser(preferredLocale: Locale | undefined) { onyxOperationToCleanUpAnonymousUser, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -713,7 +713,7 @@ function signInWithShortLivedAuthToken(authToken: string, isSAML = false) { * @param validateCode - 6 digit code required for login */ function signIn(validateCode: string, preferredLocale: Locale | undefined, twoFactorAuthCode?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -746,7 +746,7 @@ function signIn(validateCode: string, preferredLocale: Locale | undefined, twoFa onyxOperationToCleanUpAnonymousUser, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -780,7 +780,7 @@ function signInWithValidateCode(accountID: number, code: string, preferredLocale const validateCode = twoFactorAuthCode ? credentials.validateCode : code; const onyxOperationToCleanUpAnonymousUser = buildOnyxDataToCleanUpAnonymousUser(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -822,7 +822,7 @@ function signInWithValidateCode(accountID: number, code: string, preferredLocale onyxOperationToCleanUpAnonymousUser, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1059,7 +1059,7 @@ function requestUnlinkValidationLink() { } function unlinkLogin(accountID: number, validateCode: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1069,7 +1069,7 @@ function unlinkLogin(accountID: number, validateCode: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1086,7 +1086,7 @@ function unlinkLogin(accountID: number, validateCode: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1112,7 +1112,7 @@ function unlinkLogin(accountID: number, validateCode: string) { * Toggles two-factor authentication based on the `enable` parameter */ function toggleTwoFactorAuth(enable: boolean, twoFactorAuthCode = '') { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1122,7 +1122,7 @@ function toggleTwoFactorAuth(enable: boolean, twoFactorAuthCode = '') { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1132,7 +1132,7 @@ function toggleTwoFactorAuth(enable: boolean, twoFactorAuthCode = '') { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1293,7 +1293,7 @@ const canAnonymousUserAccessRoute = (route: string) => { }; function AddWorkEmail(workEmail: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM, @@ -1304,7 +1304,7 @@ function AddWorkEmail(workEmail: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM, @@ -1314,7 +1314,7 @@ function AddWorkEmail(workEmail: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM, @@ -1343,7 +1343,7 @@ function AddWorkEmail(workEmail: string) { } function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: string, accountID: number | undefined) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, @@ -1359,7 +1359,7 @@ function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: s }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, @@ -1382,7 +1382,7 @@ function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: s }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1432,7 +1432,7 @@ function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: s function resetSMSDeliveryFailureStatus(login: string) { const params: ResetSMSDeliveryFailureStatusParams = {login}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1444,7 +1444,7 @@ function resetSMSDeliveryFailureStatus(login: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1455,7 +1455,7 @@ function resetSMSDeliveryFailureStatus(login: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, diff --git a/src/libs/actions/SidePanel.ts b/src/libs/actions/SidePanel.ts index 97597d5f85665..b887a2dcbef9f 100644 --- a/src/libs/actions/SidePanel.ts +++ b/src/libs/actions/SidePanel.ts @@ -11,7 +11,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; * @param shouldOpenOnNarrowScreen - Whether to open the side panel on narrow screen */ function openSidePanel(shouldOpenOnNarrowScreen: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: ONYXKEYS.NVP_SIDE_PANEL, onyxMethod: Onyx.METHOD.MERGE, @@ -30,7 +30,7 @@ function openSidePanel(shouldOpenOnNarrowScreen: boolean) { * @param shouldCloseOnNarrowScreen - Whether to close the side panel on narrow screen */ function closeSidePanel(shouldCloseOnNarrowScreen: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: ONYXKEYS.NVP_SIDE_PANEL, onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/libs/actions/Subscription.ts b/src/libs/actions/Subscription.ts index 6d65f7b35501a..07b9346b860d6 100644 --- a/src/libs/actions/Subscription.ts +++ b/src/libs/actions/Subscription.ts @@ -16,7 +16,7 @@ function openSubscriptionPage() { } function updateSubscriptionType(type: SubscriptionType) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -30,7 +30,7 @@ function updateSubscriptionType(type: SubscriptionType) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -44,7 +44,7 @@ function updateSubscriptionType(type: SubscriptionType) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -69,7 +69,7 @@ function updateSubscriptionType(type: SubscriptionType) { } function updateSubscriptionAutoRenew(autoRenew: boolean, disableAutoRenewReason?: FeedbackSurveyOptionID, disableAutoRenewAdditionalNote?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -83,7 +83,7 @@ function updateSubscriptionAutoRenew(autoRenew: boolean, disableAutoRenewReason? }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -96,7 +96,7 @@ function updateSubscriptionAutoRenew(autoRenew: boolean, disableAutoRenewReason? }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -123,7 +123,7 @@ function updateSubscriptionAutoRenew(autoRenew: boolean, disableAutoRenewReason? } function updateSubscriptionAddNewUsersAutomatically(addNewUsersAutomatically: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -137,7 +137,7 @@ function updateSubscriptionAddNewUsersAutomatically(addNewUsersAutomatically: bo }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -150,7 +150,7 @@ function updateSubscriptionAddNewUsersAutomatically(addNewUsersAutomatically: bo }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index a19af347ff4a6..f6e81e4e0174b 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -325,7 +325,7 @@ function buildTaskData( ) { const message = `marked as complete`; const completedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED, message); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, @@ -342,7 +342,7 @@ function buildTaskData( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`, @@ -354,7 +354,7 @@ function buildTaskData( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, @@ -465,7 +465,7 @@ function reopenTask(taskReport: OnyxEntry, parentReport: OnyxE const reopenedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED, message); const hasOutstandingChildTask = taskReport?.managerID === currentUserAccountID ? true : parentReport?.hasOutstandingChildTask; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, @@ -492,7 +492,7 @@ function reopenTask(taskReport: OnyxEntry, parentReport: OnyxE }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`, @@ -503,7 +503,7 @@ function reopenTask(taskReport: OnyxEntry, parentReport: OnyxE }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, @@ -551,7 +551,7 @@ function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task const newDescription = typeof description === 'string' ? ReportUtils.getParsedComment(description) : report.description; const reportDescription = (newDescription ?? '').trim(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, @@ -572,7 +572,7 @@ function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, @@ -592,7 +592,7 @@ function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, @@ -1110,7 +1110,7 @@ function deleteTask( optimisticData.push(...ReportUtils.getOptimisticDataForAncestors(ancestors, parentReport?.lastVisibleActionCreated ?? '', CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, @@ -1127,7 +1127,7 @@ function deleteTask( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, diff --git a/src/libs/actions/TeachersUnite.ts b/src/libs/actions/TeachersUnite.ts index 8a22ae20381e2..440f5618dadff 100644 --- a/src/libs/actions/TeachersUnite.ts +++ b/src/libs/actions/TeachersUnite.ts @@ -31,7 +31,7 @@ function referTeachersUniteVolunteer(partnerUserID: string, firstName: string, l chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, policyID, }); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT}${publicRoomReportID}`, @@ -99,7 +99,7 @@ function addSchoolPrincipal( reportActionID: expenseReportCreatedAction.reportActionID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM, @@ -147,7 +147,7 @@ function addSchoolPrincipal( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM, @@ -188,7 +188,7 @@ function addSchoolPrincipal( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM, diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 39e7487c72a2f..de3fb556ecc93 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -97,14 +97,14 @@ function closeAccount(reason: string) { // Note: successData does not need to set isLoading to false because if the CloseAccount // command succeeds, a Pusher response will clear all Onyx data. - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM, value: {isLoading: true}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM, @@ -138,7 +138,7 @@ function resendValidateCode(login: string) { * @param contactMethod - the new contact method that the user is trying to verify */ function requestContactMethodValidateCode(contactMethod: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -156,7 +156,7 @@ function requestContactMethodValidateCode(contactMethod: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -171,7 +171,7 @@ function requestContactMethodValidateCode(contactMethod: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -198,14 +198,14 @@ function requestContactMethodValidateCode(contactMethod: string) { * Sets whether the user account is subscribed to Expensify news */ function updateNewsletterSubscription(isSubscribed: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, value: {isSubscribedToNewsletter: isSubscribed}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -229,7 +229,7 @@ function updateNewsletterSubscription(isSubscribed: boolean) { function deleteContactMethod(contactMethod: string, loginList: Record, backTo?: string) { const oldLoginData = loginList[contactMethod]; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -244,7 +244,7 @@ function deleteContactMethod(contactMethod: string, loginList: Record> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -253,7 +253,7 @@ function deleteContactMethod(contactMethod: string, loginList: Record> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -363,7 +363,7 @@ function addPendingContactMethod(contactMethod: string) { * Adds a secondary login to a user's account */ function addNewContactMethod(contactMethod: string, validateCode = '') { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -383,7 +383,7 @@ function addNewContactMethod(contactMethod: string, validateCode = '') { value: {isLoading: true}, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PENDING_CONTACT_ACTION, @@ -402,7 +402,7 @@ function addNewContactMethod(contactMethod: string, validateCode = '') { value: {isLoading: false}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -424,7 +424,7 @@ function addNewContactMethod(contactMethod: string, validateCode = '') { * Requests a magic code to verify current user */ function requestValidateCodeAction() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_ACTION_CODE, @@ -440,7 +440,7 @@ function requestValidateCodeAction() { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_ACTION_CODE, @@ -457,7 +457,7 @@ function requestValidateCodeAction() { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_ACTION_CODE, @@ -487,7 +487,7 @@ function validateSecondaryLogin( formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], shouldResetActionCode?: boolean, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -959,7 +959,7 @@ function subscribeToUserEvents() { * Sync preferredSkinTone with Onyx and Server */ function updatePreferredSkinTone(skinTone: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, @@ -979,7 +979,7 @@ function updatePreferredSkinTone(skinTone: number) { */ function updateChatPriorityMode(mode: ValueOf, automatic = false) { const autoSwitchedToFocusMode = mode === CONST.PRIORITY_MODE.GSD && automatic; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIORITY_MODE, @@ -1017,14 +1017,14 @@ function togglePlatformMute(platform: Platform, mutedPlatforms: Partial> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_MUTED_PLATFORMS, value: newMutedPlatforms, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_MUTED_PLATFORMS, @@ -1062,7 +1062,7 @@ function joinScreenShare(accessToken: string, roomName: string) { * @param period YYYYMM format */ function generateStatementPDF(period: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_STATEMENT, @@ -1071,7 +1071,7 @@ function generateStatementPDF(period: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_STATEMENT, @@ -1080,7 +1080,7 @@ function generateStatementPDF(period: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_STATEMENT, @@ -1104,7 +1104,7 @@ function generateStatementPDF(period: string) { */ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], backTo?: string) { const oldDefaultContactMethod = currentEmail; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1144,7 +1144,7 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -1157,7 +1157,7 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1256,7 +1256,7 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN } function updateTheme(theme: ValueOf) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.PREFERRED_THEME, @@ -1277,7 +1277,7 @@ function updateTheme(theme: ValueOf) { * Sets a custom status */ function updateCustomStatus(status: Status) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -1300,7 +1300,7 @@ function updateCustomStatus(status: Status) { * Clears the custom status */ function clearCustomStatus() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -1341,7 +1341,7 @@ function clearDraftCustomStatus() { } function dismissReferralBanner(type: ValueOf) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_DISMISSED_REFERRAL_BANNERS, @@ -1408,7 +1408,7 @@ function setIsDebugModeEnabled(isDebugModeEnabled: boolean) { } function lockAccount() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1421,7 +1421,7 @@ function lockAccount() { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1434,7 +1434,7 @@ function lockAccount() { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, diff --git a/src/libs/actions/Wallet.ts b/src/libs/actions/Wallet.ts index e1fb3356e92f5..1504485c609e5 100644 --- a/src/libs/actions/Wallet.ts +++ b/src/libs/actions/Wallet.ts @@ -23,7 +23,7 @@ type WalletQuestionAnswer = { * identity check. Note: This happens in Web-Secure when we call Activate_Wallet during the OnfidoStep. */ function openOnfidoFlow() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { // Use Onyx.set() since we are resetting the Onfido flow completely. onyxMethod: Onyx.METHOD.SET, @@ -34,7 +34,7 @@ function openOnfidoFlow() { }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_ONFIDO, @@ -62,7 +62,7 @@ function setKYCWallSource(source?: ValueOf, chatRe * Validates a user's provided details against a series of checks */ function updatePersonalDetails(personalDetails: UpdatePersonalDetailsForWalletParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS, @@ -74,7 +74,7 @@ function updatePersonalDetails(personalDetails: UpdatePersonalDetailsForWalletPa }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS, @@ -97,7 +97,7 @@ function updatePersonalDetails(personalDetails: UpdatePersonalDetailsForWalletPa * API request to fetch the userWallet after we call VerifyIdentity */ function verifyIdentity(parameters: VerifyIdentityParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_ONFIDO, @@ -116,7 +116,7 @@ function verifyIdentity(parameters: VerifyIdentityParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_ONFIDO, @@ -127,7 +127,7 @@ function verifyIdentity(parameters: VerifyIdentityParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_ONFIDO, @@ -150,7 +150,7 @@ function verifyIdentity(parameters: VerifyIdentityParams) { * @param parameters.chatReportID When accepting the terms of wallet to pay an IOU, indicates the parent chat ID of the IOU */ function acceptWalletTerms(parameters: AcceptWalletTermsParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_TERMS, @@ -160,7 +160,7 @@ function acceptWalletTerms(parameters: AcceptWalletTermsParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_TERMS, @@ -171,7 +171,7 @@ function acceptWalletTerms(parameters: AcceptWalletTermsParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.USER_WALLET, @@ -215,7 +215,7 @@ function updateCurrentStep(currentStep: ValueOf | null function answerQuestionsForWallet(answers: WalletQuestionAnswer[], idNumber: string) { const idologyAnswers = JSON.stringify(answers); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS, @@ -225,7 +225,7 @@ function answerQuestionsForWallet(answers: WalletQuestionAnswer[], idNumber: str }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS, diff --git a/src/libs/actions/Welcome/index.ts b/src/libs/actions/Welcome/index.ts index c3c5ada15d101..1b74d7ed11ef9 100644 --- a/src/libs/actions/Welcome/index.ts +++ b/src/libs/actions/Welcome/index.ts @@ -161,7 +161,7 @@ function completeHybridAppOnboarding() { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_TRY_NEW_DOT, @@ -233,7 +233,7 @@ function setSelfTourViewed(shouldUpdateOnyxDataOnlyLocally = false) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_ONBOARDING, diff --git a/src/libs/actions/Workflow.ts b/src/libs/actions/Workflow.ts index 52f3cc015ec82..5e54358204221 100644 --- a/src/libs/actions/Workflow.ts +++ b/src/libs/actions/Workflow.ts @@ -41,7 +41,7 @@ function createApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.APPROVAL_WORKFLOW, @@ -57,7 +57,7 @@ function createApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -68,7 +68,7 @@ function createApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -104,7 +104,7 @@ function updateApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, membersToRem return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.APPROVAL_WORKFLOW, @@ -120,7 +120,7 @@ function updateApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, membersToRem }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -132,7 +132,7 @@ function updateApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, membersToRem }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -163,7 +163,7 @@ function removeApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx // If there is more than one workflow, we need to keep the advanced approval mode (first workflow is the default) const hasMoreThanOneWorkflow = Object.values(updatedEmployeeList).some((employee) => !!employee.submitsTo && employee.submitsTo !== defaultApprover); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.APPROVAL_WORKFLOW, @@ -179,7 +179,7 @@ function removeApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -190,7 +190,7 @@ function removeApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index b6e8c6976845b..91bb986ca4116 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -19,7 +19,7 @@ type SubsidiaryParam = { }; function connectPolicyToNetSuite(policyID: string, credentials: Omit) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`, @@ -76,7 +76,7 @@ function updateNetSuiteOnyxData> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -98,7 +98,7 @@ function updateNetSuiteOnyxData> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -120,7 +120,7 @@ function updateNetSuiteOnyxData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -156,7 +156,7 @@ function updateNetSuiteSyncOptionsOnyxData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -190,7 +190,7 @@ function updateNetSuiteSyncOptionsOnyxData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -212,7 +212,7 @@ function updateNetSuiteSyncOptionsOnyxData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -777,7 +777,7 @@ function updateNetSuiteAutoSync(policyID: string | undefined, value: boolean) { if (!policyID) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -801,7 +801,7 @@ function updateNetSuiteAutoSync(policyID: string | undefined, value: boolean) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -825,7 +825,7 @@ function updateNetSuiteAutoSync(policyID: string | undefined, value: boolean) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/QuickbooksDesktop.ts b/src/libs/actions/connections/QuickbooksDesktop.ts index c6f50ddd85333..ab3aa5f09bb88 100644 --- a/src/libs/actions/connections/QuickbooksDesktop.ts +++ b/src/libs/actions/connections/QuickbooksDesktop.ts @@ -19,7 +19,7 @@ function buildOnyxDataForMultipleQuickbooksExportConfigurations, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -37,7 +37,7 @@ function buildOnyxDataForMultipleQuickbooksExportConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -57,7 +57,7 @@ function buildOnyxDataForMultipleQuickbooksExportConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -89,7 +89,7 @@ function buildOnyxDataForQuickbooksExportConfiguration> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -115,7 +115,7 @@ function buildOnyxDataForQuickbooksExportConfiguration> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -141,7 +141,7 @@ function buildOnyxDataForQuickbooksExportConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -177,7 +177,7 @@ function buildOnyxDataForQuickbooksDesktopMappingsConfiguration, oldSettingValue?: Partial, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -201,7 +201,7 @@ function buildOnyxDataForQuickbooksDesktopMappingsConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -225,7 +225,7 @@ function buildOnyxDataForQuickbooksDesktopMappingsConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -258,7 +258,7 @@ function buildOnyxDataForQuickbooksConfiguration, oldSettingValue?: Partial, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -280,7 +280,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -302,7 +302,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/QuickbooksOnline.ts b/src/libs/actions/connections/QuickbooksOnline.ts index e4160c589ccc6..1296e8862fe1e 100644 --- a/src/libs/actions/connections/QuickbooksOnline.ts +++ b/src/libs/actions/connections/QuickbooksOnline.ts @@ -35,7 +35,7 @@ function buildOnyxDataForMultipleQuickbooksConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -53,7 +53,7 @@ function buildOnyxDataForMultipleQuickbooksConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -73,7 +73,7 @@ function buildOnyxDataForMultipleQuickbooksConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -105,7 +105,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -129,7 +129,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -153,7 +153,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts index 6a07eeb564bac..b135b5c8ad1f9 100644 --- a/src/libs/actions/connections/SageIntacct.ts +++ b/src/libs/actions/connections/SageIntacct.ts @@ -39,7 +39,7 @@ function prepareOnyxDataForMappingUpdate( mappingValue: boolean | SageIntacctMappingValue, oldMappingValue?: boolean | SageIntacctMappingValue, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -63,7 +63,7 @@ function prepareOnyxDataForMappingUpdate( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -87,7 +87,7 @@ function prepareOnyxDataForMappingUpdate( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -175,7 +175,7 @@ function UpdateSageIntacctTaxSolutionID(policyID: string | undefined, taxSolutio if (!policyID) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -199,7 +199,7 @@ function UpdateSageIntacctTaxSolutionID(policyID: string | undefined, taxSolutio }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -223,7 +223,7 @@ function UpdateSageIntacctTaxSolutionID(policyID: string | undefined, taxSolutio }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -251,7 +251,7 @@ function updateSageIntacctSyncTaxConfiguration(policyID: string | undefined, ena if (!policyID) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -275,7 +275,7 @@ function updateSageIntacctSyncTaxConfiguration(policyID: string | undefined, ena }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -299,7 +299,7 @@ function updateSageIntacctSyncTaxConfiguration(policyID: string | undefined, ena }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -330,7 +330,7 @@ function prepareOnyxDataForUserDimensionUpdate( oldDimensionName: string, pendingAction: OnyxCommon.PendingAction, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -352,7 +352,7 @@ function prepareOnyxDataForUserDimensionUpdate( const pendingActionAfterFailure = pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD ? pendingAction : null; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -374,7 +374,7 @@ function prepareOnyxDataForUserDimensionUpdate( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -447,7 +447,7 @@ function prepareOnyxDataForExportUpdate(policyID: string, settingName: keyof Sag const exporterOptimisticData = settingName === CONST.SAGE_INTACCT_CONFIG.EXPORTER ? {exporter: settingValue} : {}; const exporterErrorData = settingName === CONST.SAGE_INTACCT_CONFIG.EXPORTER ? {exporter: oldSettingValue} : {}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -472,7 +472,7 @@ function prepareOnyxDataForExportUpdate(policyID: string, settingName: keyof Sag }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -497,7 +497,7 @@ function prepareOnyxDataForExportUpdate(policyID: string, settingName: keyof Sag }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -638,7 +638,7 @@ function removeSageIntacctUserDimensionsByName(dimensions: SageIntacctDimension[ } function prepareOnyxDataForConfigUpdate(policyID: string, settingName: keyof SageIntacctConnectionsConfig, settingValue: string | boolean | null, oldSettingValue?: string | boolean | null) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -660,7 +660,7 @@ function prepareOnyxDataForConfigUpdate(policyID: string, settingName: keyof Sag }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -682,7 +682,7 @@ function prepareOnyxDataForConfigUpdate(policyID: string, settingName: keyof Sag }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -707,7 +707,7 @@ function prepareOnyxDataForConfigUpdate(policyID: string, settingName: keyof Sag } function prepareOnyxDataForSyncUpdate(policyID: string, settingName: keyof Connections['intacct']['config']['sync'], settingValue: string | boolean, oldSettingValue?: string | boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -731,7 +731,7 @@ function prepareOnyxDataForSyncUpdate(policyID: string, settingName: keyof Conne }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -755,7 +755,7 @@ function prepareOnyxDataForSyncUpdate(policyID: string, settingName: keyof Conne }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -780,7 +780,7 @@ function prepareOnyxDataForSyncUpdate(policyID: string, settingName: keyof Conne } function prepareOnyxDataForAutoSyncUpdate(policyID: string, settingName: keyof Connections['intacct']['config']['autoSync'], settingValue: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -804,7 +804,7 @@ function prepareOnyxDataForAutoSyncUpdate(policyID: string, settingName: keyof C }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -828,7 +828,7 @@ function prepareOnyxDataForAutoSyncUpdate(policyID: string, settingName: keyof C }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/Xero.ts b/src/libs/actions/connections/Xero.ts index ff6e46e129408..78e943a4a72af 100644 --- a/src/libs/actions/connections/Xero.ts +++ b/src/libs/actions/connections/Xero.ts @@ -131,7 +131,7 @@ function prepareXeroOptimisticData, oldSettingValue?: Partial | null, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -149,7 +149,7 @@ function prepareXeroOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -167,7 +167,7 @@ function prepareXeroOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -193,7 +193,7 @@ function prepareXeroExportOptimisticData, oldSettingValue?: Partial | null, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -213,7 +213,7 @@ function prepareXeroExportOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -233,7 +233,7 @@ function prepareXeroExportOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -259,7 +259,7 @@ function prepareXeroSyncOptimisticData, oldSettingValue?: Partial | null, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -279,7 +279,7 @@ function prepareXeroSyncOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -299,7 +299,7 @@ function prepareXeroSyncOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 5aae863c6e538..604022920eee1 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -18,7 +18,7 @@ function removePolicyConnection(policy: Policy, connectionName: PolicyConnection const policyID = policy.id; const workspaceAccountID = policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -135,7 +135,7 @@ function syncConnection(policy: Policy | undefined, connectionName: PolicyConnec if (!syncConnectionData) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`, @@ -147,7 +147,7 @@ function syncConnection(policy: Policy | undefined, connectionName: PolicyConnec }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`, @@ -179,7 +179,7 @@ function updateManyPolicyConnectionConfigs> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -197,7 +197,7 @@ function updateManyPolicyConnectionConfigs> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -217,7 +217,7 @@ function updateManyPolicyConnectionConfigs> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -301,7 +301,7 @@ function copyExistingPolicyConnection(connectedPolicyID: string, targetPolicyID: stageInProgress = null; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${targetPolicyID}`, diff --git a/src/libs/getFirstAlphaNumericCharacter.ts b/src/libs/getFirstAlphaNumericCharacter.ts index 734ab1129a8d1..3c890a4ca0e79 100644 --- a/src/libs/getFirstAlphaNumericCharacter.ts +++ b/src/libs/getFirstAlphaNumericCharacter.ts @@ -1,10 +1,8 @@ function getFirstAlphaNumericCharacter(str = '') { - return ( - str - .normalize('NFD') - .replaceAll(/[^0-9a-z]/gi, '') - .toUpperCase()[0] ?? '' - ); + return (str + .normalize('NFD') + .replaceAll(/[^0-9a-z]/gi, '') + .toUpperCase()[0] ?? ''); } export default getFirstAlphaNumericCharacter; diff --git a/src/utils/createDummySharedValue.ts b/src/utils/createDummySharedValue.ts index d9702b43ef906..cbb3790fb5524 100644 --- a/src/utils/createDummySharedValue.ts +++ b/src/utils/createDummySharedValue.ts @@ -7,13 +7,13 @@ import type {SharedValue} from 'react-native-reanimated'; * @returns */ const createDummySharedValue = (value?: T): SharedValue => - ({ + (({ value, get: () => value, set: () => {}, addListener: () => value, removeListener: () => {}, - modify: () => {}, - }) as SharedValue; + modify: () => {} + }) as SharedValue); export default createDummySharedValue; From 6abfe418bc514a0011b7293cb7436bc3937b5d7d Mon Sep 17 00:00:00 2001 From: Olgierd Date: Thu, 18 Dec 2025 14:51:51 +0100 Subject: [PATCH 02/10] Codegen now modify only the files with acutal changes detected --- src/libs/getFirstAlphaNumericCharacter.ts | 10 ++++++---- src/utils/createDummySharedValue.ts | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libs/getFirstAlphaNumericCharacter.ts b/src/libs/getFirstAlphaNumericCharacter.ts index 3c890a4ca0e79..734ab1129a8d1 100644 --- a/src/libs/getFirstAlphaNumericCharacter.ts +++ b/src/libs/getFirstAlphaNumericCharacter.ts @@ -1,8 +1,10 @@ function getFirstAlphaNumericCharacter(str = '') { - return (str - .normalize('NFD') - .replaceAll(/[^0-9a-z]/gi, '') - .toUpperCase()[0] ?? ''); + return ( + str + .normalize('NFD') + .replaceAll(/[^0-9a-z]/gi, '') + .toUpperCase()[0] ?? '' + ); } export default getFirstAlphaNumericCharacter; diff --git a/src/utils/createDummySharedValue.ts b/src/utils/createDummySharedValue.ts index cbb3790fb5524..d9702b43ef906 100644 --- a/src/utils/createDummySharedValue.ts +++ b/src/utils/createDummySharedValue.ts @@ -7,13 +7,13 @@ import type {SharedValue} from 'react-native-reanimated'; * @returns */ const createDummySharedValue = (value?: T): SharedValue => - (({ + ({ value, get: () => value, set: () => {}, addListener: () => value, removeListener: () => {}, - modify: () => {} - }) as SharedValue); + modify: () => {}, + }) as SharedValue; export default createDummySharedValue; From 86c2370acc4747b1d802762c3c92f0f9a044eaa1 Mon Sep 17 00:00:00 2001 From: Olgierd Date: Thu, 18 Dec 2025 15:45:39 +0100 Subject: [PATCH 03/10] Replace default updateOnyx union type in src/libs/actions/Report.ts --- src/libs/actions/Report.ts | 186 ++++++++++++++++++++----------------- 1 file changed, 99 insertions(+), 87 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 0be98707ea04f..b230ab4ec6cb5 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -668,7 +668,7 @@ function addActions(reportID: string, notifyReportID: string, ancestors: Ancesto successReportActions[actionKey] = {pendingAction: null, isOptimisticAction: null}; } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -702,7 +702,7 @@ function addActions(reportID: string, notifyReportID: string, ancestors: Ancesto }; } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -788,7 +788,7 @@ function reportActionsExist(reportID: string): boolean { } function updateChatName(reportID: string, reportName: string, type: typeof CONST.REPORT.CHAT_TYPE.GROUP | typeof CONST.REPORT.CHAT_TYPE.TRIP_ROOM) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -804,7 +804,7 @@ function updateChatName(reportID: string, reportName: string, type: typeof CONST }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -815,7 +815,7 @@ function updateChatName(reportID: string, reportName: string, type: typeof CONST }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -844,7 +844,7 @@ function updateChatName(reportID: string, reportName: string, type: typeof CONST */ function buildUpdateReportAvatarOnyxData(reportID: string, file?: File | CustomRNImageManipulatorResult) { // If we have no file that means we are removing the avatar. - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -861,7 +861,7 @@ function buildUpdateReportAvatarOnyxData(reportID: string, file?: File | CustomR ]; const fetchedReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -874,7 +874,7 @@ function buildUpdateReportAvatarOnyxData(reportID: string, file?: File | CustomR }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -1570,7 +1570,7 @@ function getOlderActions(reportID: string | undefined, reportActionID: string | return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1581,7 +1581,7 @@ function getOlderActions(reportID: string | undefined, reportActionID: string | }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1591,7 +1591,7 @@ function getOlderActions(reportID: string | undefined, reportActionID: string | }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1628,7 +1628,7 @@ function getNewerActions(reportID: string | undefined, reportActionID: string | return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1639,7 +1639,7 @@ function getNewerActions(reportID: string | undefined, reportActionID: string | }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1649,7 +1649,7 @@ function getNewerActions(reportID: string | undefined, reportActionID: string | }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1704,7 +1704,7 @@ function readNewestAction(reportID: string | undefined, shouldResetUnreadMarker const lastReadTime = NetworkConnection.getDBTimeWithSkew(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -1829,7 +1829,7 @@ function markCommentAsUnread(reportID: string | undefined, reportAction: ReportA // Since the report action with ID 100 will be the first with a timestamp above '2014-04-01 16:07:02.998', it's the first one that will be shown as unread const lastReadTime = DateUtils.subtractMillisecondsFromDateTime(actionCreationTime, 1); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -1858,7 +1858,7 @@ function togglePinnedState(reportID: string | undefined, isPinnedChat: boolean) const pinnedValue = !isPinnedChat; // Optimistically pin/unpin the report before we send out the command - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2030,7 +2030,7 @@ function deleteReportComment( } // If the API call fails we must show the original message again, so we revert the message content back to how it was // and and remove the pendingAction so the strike-through clears - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2044,7 +2044,7 @@ function deleteReportComment( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2215,7 +2215,7 @@ function editReportComment( }, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2236,7 +2236,7 @@ function editReportComment( }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2249,7 +2249,7 @@ function editReportComment( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2307,7 +2307,7 @@ function updateNotificationPreference( return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2321,7 +2321,7 @@ function updateNotificationPreference( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2358,7 +2358,7 @@ function updateRoomVisibility(reportID: string, previousValue: RoomVisibility | return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2366,7 +2366,7 @@ function updateRoomVisibility(reportID: string, previousValue: RoomVisibility | }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2423,7 +2423,7 @@ function toggleSubscribeToChildReport( } function updateReportName(reportID: string, value: string, previousValue: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2435,7 +2435,7 @@ function updateReportName(reportID: string, value: string, previousValue: string }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2451,7 +2451,7 @@ function updateReportName(reportID: string, value: string, previousValue: string }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2529,7 +2529,15 @@ function updateReportField( isASAPSubmitBetaEnabled, }); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.NEXT_STEP + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.REPORT_VIOLATIONS + | typeof ONYXKEYS.RECENTLY_USED_REPORT_FIELDS + > + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2580,7 +2588,7 @@ function updateReportField( }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2619,7 +2627,7 @@ function updateReportField( }); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2656,7 +2664,7 @@ function updateReportField( function deleteReportField(reportID: string, reportField: PolicyReportField) { const fieldKey = getReportFieldKey(reportField.fieldID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2671,7 +2679,7 @@ function deleteReportField(reportID: string, reportField: PolicyReportField) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2689,7 +2697,7 @@ function deleteReportField(reportID: string, reportField: PolicyReportField) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2722,7 +2730,7 @@ function updateDescription(reportID: string, currentDescription: string, newMark const optimisticDescriptionUpdatedReportAction = buildOptimisticRoomDescriptionUpdatedReportAction(parsedDescription); const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2742,7 +2750,7 @@ function updateDescription(reportID: string, currentDescription: string, newMark }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2762,7 +2770,7 @@ function updateDescription(reportID: string, currentDescription: string, newMark }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2788,14 +2796,14 @@ function updateWriteCapability(report: Report, newValue: WriteCapability) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, value: {writeCapability: newValue}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, @@ -2972,7 +2980,7 @@ function buildNewReportOptimisticData( }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2992,7 +3000,7 @@ function buildNewReportOptimisticData( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3105,7 +3113,9 @@ function addPolicyReport(policyReport: OptimisticChatReport) { // Onyx.set is used on the optimistic data so that it is present before navigating to the workspace room. With Onyx.merge the workspace room reportID is not present when // fetchReportIfNeeded is called on the ReportScreen, so openReport is called which is unnecessary since the optimistic data will be stored in Onyx. // Therefore, Onyx.set is used instead of Onyx.merge. - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT}${policyReport.reportID}`, @@ -3134,7 +3144,9 @@ function addPolicyReport(policyReport: OptimisticChatReport) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${policyReport.reportID}`, @@ -3166,7 +3178,7 @@ function addPolicyReport(policyReport: OptimisticChatReport) { value: {isLoading: false}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${policyReport.reportID}`, @@ -3287,7 +3299,7 @@ function updatePolicyRoomName(policyRoomReport: Report, policyRoomName: string) const optimisticRenamedAction = buildOptimisticRenamedRoomReportAction(policyRoomName, previousName ?? ''); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3309,7 +3321,7 @@ function updatePolicyRoomName(policyRoomReport: Report, policyRoomName: string) }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3325,7 +3337,7 @@ function updatePolicyRoomName(policyRoomReport: Report, policyRoomName: string) value: {[optimisticRenamedAction.reportActionID]: {pendingAction: null}}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3474,7 +3486,7 @@ function clearIOUError(reportID: string | undefined) { */ function addEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji, skinTone: number) { const createdAt = timezoneFormat(toZonedTime(new Date(), 'UTC'), CONST.DATE.FNS_DB_FORMAT_STRING); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, @@ -3494,7 +3506,7 @@ function addEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, @@ -3506,7 +3518,7 @@ function addEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, @@ -3534,7 +3546,7 @@ function addEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji * Uses the NEW FORMAT for "emojiReactions" */ function removeEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, @@ -3654,7 +3666,7 @@ function leaveGroupChat(reportID: string, shouldClearQuickAction: boolean) { // Use merge instead of set to avoid deleting the report too quickly, which could cause a brief "not found" page to appear. // The remaining parts of the report object will be removed after the API call is successful. - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3684,7 +3696,7 @@ function leaveGroupChat(reportID: string, shouldClearQuickAction: boolean) { // Ensure that any remaining data is removed upon successful completion, even if the server sends a report removal response. // This is done to prevent the removal update from lingering in the applyHTTPSOnyxUpdates function. - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3692,7 +3704,7 @@ function leaveGroupChat(reportID: string, shouldClearQuickAction: boolean) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3730,7 +3742,7 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal // If a workspace member is leaving a workspace room, they don't actually lose the room from Onyx. // Instead, their notification preference just gets set to "hidden". // Same applies for chat threads too - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3782,7 +3794,7 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3912,7 +3924,7 @@ function buildInviteToRoomOnyxData(reportID: string, inviteeEmailsToAccountIDs: ]; successData.push(...newPersonalDetailsOnyxData.finallyData); - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4003,7 +4015,7 @@ function updateGroupChatMemberRoles(reportID: string, accountIDList: number[], r }; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4011,7 +4023,7 @@ function updateGroupChatMemberRoles(reportID: string, accountIDList: number[], r }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4043,7 +4055,7 @@ function removeFromRoom(reportID: string, targetAccountIDs: number[]) { } const pendingChatMembers = getPendingChatMembers(targetAccountIDs, reportMetadata?.pendingChatMembers ?? [], CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4053,7 +4065,7 @@ function removeFromRoom(reportID: string, targetAccountIDs: number[]) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4065,7 +4077,7 @@ function removeFromRoom(reportID: string, targetAccountIDs: number[]) { // We need to add success data here since in high latency situations, // the OpenRoomMembersPage call has the chance of overwriting the optimistic data we set above. - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4159,7 +4171,7 @@ function flagComment(reportAction: OnyxEntry, severity: string, or ...(shouldHideMessage ? {translationKey: '', type: 'COMMENT', html: '', text: '', isEdited: true} : {}), }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -4196,7 +4208,7 @@ function flagComment(reportAction: OnyxEntry, severity: string, or }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -4218,7 +4230,7 @@ function flagComment(reportAction: OnyxEntry, severity: string, or }); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -4243,7 +4255,7 @@ function flagComment(reportAction: OnyxEntry, severity: string, or /** Updates a given user's private notes on a report */ const updatePrivateNotes = (reportID: string, accountID: number, note: string) => { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4259,7 +4271,7 @@ const updatePrivateNotes = (reportID: string, accountID: number, note: string) = }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4274,7 +4286,7 @@ const updatePrivateNotes = (reportID: string, accountID: number, note: string) = }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4303,7 +4315,7 @@ function getReportPrivateNote(reportID: string | undefined) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4313,7 +4325,7 @@ function getReportPrivateNote(reportID: string | undefined) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4323,7 +4335,7 @@ function getReportPrivateNote(reportID: string | undefined) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4463,7 +4475,7 @@ function searchForReports(searchInput: string, policyID?: string) { return; } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_SEARCHING_FOR_REPORTS, @@ -4471,7 +4483,7 @@ function searchForReports(searchInput: string, policyID?: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_SEARCHING_FOR_REPORTS, @@ -4574,7 +4586,7 @@ function resolveActionableMentionWhisper( lastActorAccountID: report?.lastActorAccountID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4594,7 +4606,7 @@ function resolveActionableMentionWhisper( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4658,7 +4670,7 @@ function resolveActionableReportMentionWhisper( lastActorAccountID: report?.lastActorAccountID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportId}`, @@ -4677,7 +4689,7 @@ function resolveActionableReportMentionWhisper( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportId}`, @@ -4716,7 +4728,7 @@ function dismissTrackExpenseActionableWhisper(reportID: string | undefined, repo resolution: CONST.REPORT.ACTIONABLE_TRACK_EXPENSE_WHISPER_RESOLUTION.NOTHING, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4731,7 +4743,7 @@ function dismissTrackExpenseActionableWhisper(reportID: string | undefined, repo }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4761,7 +4773,7 @@ function exportToIntegration(reportID: string, connectionName: ConnectionName) { const action = buildOptimisticExportIntegrationAction(connectionName); const optimisticReportActionID = action.reportActionID; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4771,7 +4783,7 @@ function exportToIntegration(reportID: string, connectionName: ConnectionName) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4800,7 +4812,7 @@ function markAsManuallyExported(reportID: string, connectionName: ConnectionName const label = CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]; const optimisticReportActionID = action.reportActionID; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4810,7 +4822,7 @@ function markAsManuallyExported(reportID: string, connectionName: ConnectionName }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4822,7 +4834,7 @@ function markAsManuallyExported(reportID: string, connectionName: ConnectionName }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4873,7 +4885,7 @@ function exportReportToCSV({reportID, transactionIDList}: ExportReportCSVParams, } function exportReportToPDF({reportID}: ExportReportPDFParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.NVP_EXPENSIFY_REPORT_PDF_FILENAME}${reportID}`, @@ -4881,7 +4893,7 @@ function exportReportToPDF({reportID}: ExportReportPDFParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NVP_EXPENSIFY_REPORT_PDF_FILENAME}${reportID}`, From 0fab38657895c23cbe5d0b90321593d65fdc1f03 Mon Sep 17 00:00:00 2001 From: Olgierd Date: Thu, 18 Dec 2025 16:33:56 +0100 Subject: [PATCH 04/10] Replace default updateOnyx union type in src/libs/actions/IOU.ts --- src/libs/actions/IOU.ts | 84 ++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 30 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index c3381b0b394a8..5a94465893dc9 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2451,7 +2451,9 @@ function buildOnyxDataForInvoice(invoiceParams: BuildOnyxDataForInvoiceParams): const errorKey = DateUtils.getMicroseconds(); - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chat.report?.reportID}`, @@ -3151,7 +3153,7 @@ function getDeleteTrackExpenseInformation( }, ); - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`, @@ -7844,7 +7846,9 @@ function startSplitBill({ }); } - const successData: OnyxUpdate[] = [ + const successData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${splitChatReport.reportID}`, @@ -7879,7 +7883,9 @@ function startSplitBill({ }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${splitTransaction.transactionID}`, @@ -8953,7 +8959,9 @@ function cleanUpMoneyRequest( // Onyx operations to delete the transaction, update the IOU report action and chat report action const reportActionsOnyxUpdates: OnyxUpdate[] = []; - const onyxUpdates: OnyxUpdate[] = [ + const onyxUpdates: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -9158,7 +9166,15 @@ function deleteMoneyRequest({ // STEP 2: Build Onyx data // The logic mostly resembles the cleanUpMoneyRequest function - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.SNAPSHOT + > + > = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -9680,7 +9696,7 @@ function getSendMoneyParams({ } : undefined; - const optimisticMetaData: OnyxUpdate[] = [ + const optimisticMetaData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${chatReport.reportID}`, @@ -9796,7 +9812,9 @@ function getSendMoneyParams({ }, ); - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${optimisticTransaction.transactionID}`, @@ -9879,7 +9897,6 @@ function getSendMoneyParams({ }); } - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const optimisticData: OnyxUpdate[] = [ optimisticChatReportData, @@ -10109,7 +10126,7 @@ function getReportFromHoldRequestsOnyxData( bringHeldTransactionsBack[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = transaction; } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`, @@ -11054,7 +11071,7 @@ function reopenReport( const optimisticData: OnyxUpdate[] = [optimisticIOUReportData, optimisticReportActionsData, optimisticNextStepData]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11076,7 +11093,7 @@ function reopenReport( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11390,7 +11407,7 @@ function unapproveExpenseReport( const optimisticData: OnyxUpdate[] = [optimisticIOUReportData, optimisticReportActionData, optimisticNextStepData]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11412,7 +11429,7 @@ function unapproveExpenseReport( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11603,7 +11620,7 @@ function submitReport( }, }); - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, @@ -11699,7 +11716,7 @@ function cancelPayment( const expenseReportActions = getAllReportActions(expenseReport.reportID); const iouCreatedAction = Object.values(iouReportActions).find((action) => isCreatedAction(action)); const expenseCreatedAction = Object.values(expenseReportActions).find((action) => isCreatedAction(action)); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11744,7 +11761,7 @@ function cancelPayment( value: optimisticNextStepDeprecated, }); - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, @@ -11765,7 +11782,7 @@ function cancelPayment( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -12038,7 +12055,7 @@ function detachReceipt(transactionID: string | undefined, transactionPolicy: Ony }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12049,7 +12066,9 @@ function detachReceipt(transactionID: string | undefined, transactionPolicy: Ony }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12481,7 +12500,7 @@ function putOnHold(transactionID: string, comment: string, initialReportID: stri optimisticData.push(parentActionData); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12491,7 +12510,9 @@ function putOnHold(transactionID: string, comment: string, initialReportID: stri }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12629,7 +12650,9 @@ function unholdRequest(transactionID: string, reportID: string) { const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`]; const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -12650,7 +12673,6 @@ function unholdRequest(transactionID: string, reportID: string) { { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 value: transactionViolations?.filter((violation) => violation.name !== CONST.VIOLATIONS.HOLD) ?? [], }, { @@ -12676,7 +12698,7 @@ function unholdRequest(transactionID: string, reportID: string) { }); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12689,7 +12711,9 @@ function unholdRequest(transactionID: string, reportID: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -13393,7 +13417,7 @@ function dismissRejectUseExplanation() { value: true, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_DISMISSED_REJECT_USE_EXPLANATION, @@ -14166,7 +14190,7 @@ function markRejectViolationAsResolved(transactionID: string, reportID?: string) const optimisticMarkedAsResolvedReportAction = buildOptimisticMarkedAsResolvedReportAction(); // Build optimistic data - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -14182,7 +14206,7 @@ function markRejectViolationAsResolved(transactionID: string, reportID?: string) }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -14194,7 +14218,7 @@ function markRejectViolationAsResolved(transactionID: string, reportID?: string) }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, From 7e7b533f1ea5dab0e59b26bebc86d3b1fcd55768 Mon Sep 17 00:00:00 2001 From: Olgierd Date: Thu, 18 Dec 2025 16:43:48 +0100 Subject: [PATCH 05/10] Replace default updateOnyx union type in src/libs/actions/Policy/Policy.ts --- src/libs/actions/Policy/Policy.ts | 208 +++++++++++++++--------------- 1 file changed, 105 insertions(+), 103 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 4f053035f3c0e..39af2c12b0546 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -641,7 +641,7 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { function setWorkspaceAutoHarvesting(policy: Policy, enabled: boolean) { const policyID = policy.id; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -658,7 +658,7 @@ function setWorkspaceAutoHarvesting(policy: Policy, enabled: boolean) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -675,7 +675,7 @@ function setWorkspaceAutoHarvesting(policy: Policy, enabled: boolean) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -698,7 +698,7 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf const wasPolicyOnManualReporting = PolicyUtils.getCorrectedAutoReportingFrequency(policy) === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -726,7 +726,7 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -739,7 +739,7 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -762,7 +762,7 @@ function setWorkspaceAutoReportingMonthlyOffset(policyID: string | undefined, au // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -773,7 +773,7 @@ function setWorkspaceAutoReportingMonthlyOffset(policyID: string | undefined, au }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -785,7 +785,7 @@ function setWorkspaceAutoReportingMonthlyOffset(policyID: string | undefined, au }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -809,7 +809,7 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo approvalMode, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -820,7 +820,7 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -834,7 +834,7 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -860,7 +860,7 @@ function setWorkspacePayer(policyID: string, reimburserEmail: string) { // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -873,7 +873,7 @@ function setWorkspacePayer(policyID: string, reimburserEmail: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -884,7 +884,7 @@ function setWorkspacePayer(policyID: string, reimburserEmail: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -979,7 +979,7 @@ function setWorkspaceReimbursement({policyID, reimbursementChoice, bankAccountID const policy = getPolicy(policyID); const lastUsedPaymentMethod = typeof lastPaymentMethod === 'string' ? lastPaymentMethod : lastPaymentMethod?.expense?.name; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -994,7 +994,7 @@ function setWorkspaceReimbursement({policyID, reimbursementChoice, bankAccountID }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1026,7 +1026,7 @@ function setWorkspaceReimbursement({policyID, reimbursementChoice, bankAccountID }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1052,7 +1052,9 @@ function leaveWorkspace(policyID?: string) { const policy = deprecatedAllPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]; const workspaceChats = ReportUtils.getAllWorkspaceReports(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1067,14 +1069,14 @@ function leaveWorkspace(policyID?: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: null, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1176,7 +1178,7 @@ function addBillingCardAndRequestPolicyOwnerChange( const {cardNumber, cardYear, cardMonth, cardCVV, addressName, addressZip, currency} = cardData; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1189,7 +1191,7 @@ function addBillingCardAndRequestPolicyOwnerChange( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1203,7 +1205,7 @@ function addBillingCardAndRequestPolicyOwnerChange( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1248,7 +1250,7 @@ function addBillingCardAndRequestPolicyOwnerChange( * */ function verifySetupIntentAndRequestPolicyOwnerChange(policyID: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1261,7 +1263,7 @@ function verifySetupIntentAndRequestPolicyOwnerChange(policyID: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1275,7 +1277,7 @@ function verifySetupIntentAndRequestPolicyOwnerChange(policyID: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1468,7 +1470,7 @@ function createPolicyExpenseChats( * Updates a workspace avatar image */ function updateWorkspaceAvatar(policyID: string, file: File) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1484,7 +1486,7 @@ function updateWorkspaceAvatar(policyID: string, file: File) { }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1495,7 +1497,7 @@ function updateWorkspaceAvatar(policyID: string, file: File) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1520,7 +1522,7 @@ function deleteWorkspaceAvatar(policyID: string) { // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1536,7 +1538,7 @@ function deleteWorkspaceAvatar(policyID: string) { }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1547,7 +1549,7 @@ function deleteWorkspaceAvatar(policyID: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1626,7 +1628,7 @@ function updateGeneralSettings(policyID: string | undefined, name: string, curre } } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { // We use SET because it's faster than merge and avoids a race condition when setting the currency and navigating the user to the Bank account page in confirmCurrencyChangeAndHideModal onyxMethod: Onyx.METHOD.SET, @@ -1659,7 +1661,7 @@ function updateGeneralSettings(policyID: string | undefined, name: string, curre }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1688,7 +1690,7 @@ function updateGeneralSettings(policyID: string | undefined, name: string, curre errorFields.outputCurrency = ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.editor.genericFailureMessage'); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1747,7 +1749,7 @@ function updateWorkspaceDescription(policyID: string, description: string, curre } const parsedDescription = ReportUtils.getParsedComment(description); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1762,7 +1764,7 @@ function updateWorkspaceDescription(policyID: string, description: string, curre }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1773,7 +1775,7 @@ function updateWorkspaceDescription(policyID: string, description: string, curre }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1830,7 +1832,7 @@ function updateAddress(policyID: string, newAddress: CompanyAddress) { 'data[zipCode]': newAddress.zipCode, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1843,7 +1845,7 @@ function updateAddress(policyID: string, newAddress: CompanyAddress) { }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -2020,7 +2022,7 @@ function createDraftInitialWorkspace( const shouldEnableWorkflowsByDefault = !introSelected?.choice || introSelected.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM || introSelected.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`, @@ -2596,7 +2598,7 @@ function createDraftWorkspace( const shouldEnableWorkflowsByDefault = !introSelected?.choice || introSelected.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM || introSelected.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`, @@ -3045,7 +3047,7 @@ function openPolicyReceiptPartnersPage(policyID?: string) { } function removePolicyReceiptPartnersConnection(policyID: string, partnerName: string, receiptPartnerData?: UberReceiptPartner) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3057,7 +3059,7 @@ function removePolicyReceiptPartnersConnection(policyID: string, partnerName: st }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3069,7 +3071,7 @@ function removePolicyReceiptPartnersConnection(policyID: string, partnerName: st }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3094,7 +3096,7 @@ function togglePolicyUberAutoInvite(policyID: string | undefined, enabled: boole return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3103,14 +3105,14 @@ function togglePolicyUberAutoInvite(policyID: string | undefined, enabled: boole }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, value: {receiptPartners: {uber: {pendingFields: {autoInvite: null}}}}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3129,7 +3131,7 @@ function changePolicyUberBillingAccount(policyID: string | undefined, email: str return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3138,14 +3140,14 @@ function changePolicyUberBillingAccount(policyID: string | undefined, email: str }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, value: {receiptPartners: {uber: {pendingFields: {centralBillingAccountEmail: null}}}}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3164,7 +3166,7 @@ function togglePolicyUberAutoRemove(policyID: string | undefined, enabled: boole return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3173,14 +3175,14 @@ function togglePolicyUberAutoRemove(policyID: string | undefined, enabled: boole }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, value: {receiptPartners: {uber: {pendingFields: {autoRemove: null}}}}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3232,7 +3234,7 @@ function inviteWorkspaceEmployeesToUber(policyID: string, emails: string[]) { return acc; }, {}); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3245,7 +3247,7 @@ function inviteWorkspaceEmployeesToUber(policyID: string, emails: string[]) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3258,7 +3260,7 @@ function inviteWorkspaceEmployeesToUber(policyID: string, emails: string[]) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3323,7 +3325,7 @@ function openPolicyTaxesPage(policyID: string) { function openPolicyExpensifyCardsPage(policyID: string, workspaceAccountID: number) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -3333,7 +3335,7 @@ function openPolicyExpensifyCardsPage(policyID: string, workspaceAccountID: numb }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -3343,7 +3345,7 @@ function openPolicyExpensifyCardsPage(policyID: string, workspaceAccountID: numb }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -3424,7 +3426,7 @@ function updateMemberCustomField(policyID: string, login: string, customFieldTyp return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3433,7 +3435,7 @@ function updateMemberCustomField(policyID: string, login: string, customFieldTyp }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3442,7 +3444,7 @@ function updateMemberCustomField(policyID: string, login: string, customFieldTyp }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -5687,7 +5689,7 @@ function setPolicyDefaultReportTitle(policyID: string, customName: string) { const previousReportTitleField = policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE] ?? {}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5702,7 +5704,7 @@ function setPolicyDefaultReportTitle(policyID: string, customName: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5715,7 +5717,7 @@ function setPolicyDefaultReportTitle(policyID: string, customName: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5762,7 +5764,7 @@ function setPolicyPreventMemberCreatedTitle(policyID: string, enforced: boolean) const previousReportTitleField = policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE] ?? {}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5774,7 +5776,7 @@ function setPolicyPreventMemberCreatedTitle(policyID: string, enforced: boolean) }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5787,7 +5789,7 @@ function setPolicyPreventMemberCreatedTitle(policyID: string, enforced: boolean) }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5828,7 +5830,7 @@ function setPolicyPreventSelfApproval(policyID: string, preventSelfApproval: boo return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5841,7 +5843,7 @@ function setPolicyPreventSelfApproval(policyID: string, preventSelfApproval: boo }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5854,7 +5856,7 @@ function setPolicyPreventSelfApproval(policyID: string, preventSelfApproval: boo }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5899,7 +5901,7 @@ function setPolicyAutomaticApprovalLimit(policyID: string, limit: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5912,7 +5914,7 @@ function setPolicyAutomaticApprovalLimit(policyID: string, limit: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5927,7 +5929,7 @@ function setPolicyAutomaticApprovalLimit(policyID: string, limit: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5974,7 +5976,7 @@ function setPolicyAutomaticApprovalRate(policyID: string, auditRate: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5989,7 +5991,7 @@ function setPolicyAutomaticApprovalRate(policyID: string, auditRate: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6004,7 +6006,7 @@ function setPolicyAutomaticApprovalRate(policyID: string, auditRate: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6053,7 +6055,7 @@ function enableAutoApprovalOptions(policyID: string, enabled: boolean) { limit: enabled ? CONST.POLICY.AUTO_APPROVE_REPORTS_UNDER_SUGGESTED_CENTS : 0, }; const autoApprovalFailureValues = {autoApproval: {limit: policy?.autoApproval?.limit, auditRate: policy?.autoApproval?.auditRate, pendingFields: null}}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6073,7 +6075,7 @@ function enableAutoApprovalOptions(policyID: string, enabled: boolean) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6086,7 +6088,7 @@ function enableAutoApprovalOptions(policyID: string, enabled: boolean) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6128,7 +6130,7 @@ function setPolicyAutoReimbursementLimit(policyID: string, limit: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6143,7 +6145,7 @@ function setPolicyAutoReimbursementLimit(policyID: string, limit: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6159,7 +6161,7 @@ function setPolicyAutoReimbursementLimit(policyID: string, limit: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6201,7 +6203,7 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean) const autoReimbursementFailureValues = {autoReimbursement: {limit: policy?.autoReimbursement?.limit, pendingFields: null}}; const autoReimbursementValues = {limit: enabled ? CONST.POLICY.AUTO_REIMBURSEMENT_LIMIT_SUGGESTED_CENTS : CONST.POLICY.AUTO_REIMBURSEMENT_LIMIT_DEFAULT_CENTS}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6220,7 +6222,7 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean) }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6234,7 +6236,7 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean) }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6280,7 +6282,7 @@ function updateInvoiceCompanyName(policyID: string, companyName: string) { // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6295,7 +6297,7 @@ function updateInvoiceCompanyName(policyID: string, companyName: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6309,7 +6311,7 @@ function updateInvoiceCompanyName(policyID: string, companyName: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6344,7 +6346,7 @@ function updateInvoiceCompanyWebsite(policyID: string, companyWebsite: string) { // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6359,7 +6361,7 @@ function updateInvoiceCompanyWebsite(policyID: string, companyWebsite: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6373,7 +6375,7 @@ function updateInvoiceCompanyWebsite(policyID: string, companyWebsite: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6401,7 +6403,7 @@ function updateInvoiceCompanyWebsite(policyID: string, companyWebsite: string) { * Validates user account and returns a list of accessible policies. */ function getAccessiblePolicies(validateCode?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES, @@ -6412,7 +6414,7 @@ function getAccessiblePolicies(validateCode?: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES, @@ -6423,7 +6425,7 @@ function getAccessiblePolicies(validateCode?: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES, @@ -6449,21 +6451,21 @@ function clearGetAccessiblePoliciesErrors() { * Call the API to calculate the bill for the new dot */ function calculateBillNewDot() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_BILL_WHEN_DOWNGRADE, value: true, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_BILL_WHEN_DOWNGRADE, value: false, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_BILL_WHEN_DOWNGRADE, @@ -6483,7 +6485,7 @@ function calculateBillNewDot() { * Call the API to pay and downgrade */ function payAndDowngrade() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.BILLING_RECEIPT_DETAILS, @@ -6493,7 +6495,7 @@ function payAndDowngrade() { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.BILLING_RECEIPT_DETAILS, @@ -6503,7 +6505,7 @@ function payAndDowngrade() { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.BILLING_RECEIPT_DETAILS, From 37887b1612511c9f0dc1ae69de97f05a077b4c6d Mon Sep 17 00:00:00 2001 From: Olgierd Date: Thu, 18 Dec 2025 16:52:38 +0100 Subject: [PATCH 06/10] Replace updateOnyx default union type in src/libs/actions/{Card,Travel,VacationDelegate}.ts --- src/libs/actions/Card.ts | 60 +++++++++++++++------------- src/libs/actions/Travel.ts | 6 +-- src/libs/actions/VacationDelegate.ts | 8 ++-- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index c692f66b1dd54..e8f7aabd20f3a 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -113,7 +113,7 @@ function reportVirtualExpensifyCardFraud(card: Card, validateCode: string) { * @param reason - reason for replacement */ function requestReplacementExpensifyCard(cardID: number, reason: ReplacementReason, validateCode: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM, @@ -131,7 +131,7 @@ function requestReplacementExpensifyCard(cardID: number, reason: ReplacementReas }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM, @@ -141,7 +141,7 @@ function requestReplacementExpensifyCard(cardID: number, reason: ReplacementReas }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM, @@ -168,7 +168,7 @@ function requestReplacementExpensifyCard(cardID: number, reason: ReplacementReas * Activates the physical Expensify card based on the last four digits of the card number */ function activatePhysicalExpensifyCard(cardLastFourDigits: string, cardID: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.CARD_LIST, @@ -181,7 +181,7 @@ function activatePhysicalExpensifyCard(cardLastFourDigits: string, cardID: numbe }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.CARD_LIST, @@ -193,7 +193,7 @@ function activatePhysicalExpensifyCard(cardLastFourDigits: string, cardID: numbe }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.CARD_LIST, @@ -257,7 +257,7 @@ function revealVirtualCardDetails(cardID: number, validateCode: string): Promise return new Promise((resolve, reject) => { const parameters: RevealExpensifyCardDetailsParams = {cardID, validateCode}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -265,7 +265,7 @@ function revealVirtualCardDetails(cardID: number, validateCode: string): Promise }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -273,7 +273,7 @@ function revealVirtualCardDetails(cardID: number, validateCode: string): Promise }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -321,7 +321,7 @@ function revealVirtualCardDetails(cardID: number, validateCode: string): Promise function updateSettlementFrequency(workspaceAccountID: number, settlementFrequency: ValueOf, currentFrequency?: Date) { const monthlySettlementDate = settlementFrequency === CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.DAILY ? null : new Date(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -331,7 +331,7 @@ function updateSettlementFrequency(workspaceAccountID: number, settlementFrequen }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -341,7 +341,7 @@ function updateSettlementFrequency(workspaceAccountID: number, settlementFrequen }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -364,7 +364,7 @@ function updateSettlementAccount(domainName: string, workspaceAccountID: number, return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -375,7 +375,7 @@ function updateSettlementAccount(domainName: string, workspaceAccountID: number, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -386,7 +386,7 @@ function updateSettlementAccount(domainName: string, workspaceAccountID: number, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -736,7 +736,7 @@ function configureExpensifyCardsForPolicy(policyID: string, bankAccountID?: numb const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -754,7 +754,7 @@ function configureExpensifyCardsForPolicy(policyID: string, bankAccountID?: numb }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -772,7 +772,7 @@ function configureExpensifyCardsForPolicy(policyID: string, bankAccountID?: numb }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -810,7 +810,7 @@ function issueExpensifyCard(domainAccountID: number, policyID: string | undefine const {assigneeEmail, limit, limitType, cardTitle, cardType} = data; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, @@ -822,7 +822,7 @@ function issueExpensifyCard(domainAccountID: number, policyID: string | undefine }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, @@ -833,7 +833,7 @@ function issueExpensifyCard(domainAccountID: number, policyID: string | undefine }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, @@ -905,7 +905,9 @@ function toggleContinuousReconciliation(workspaceAccountID: number, shouldUseCon shouldUseContinuousReconciliation, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`, @@ -921,7 +923,9 @@ function toggleContinuousReconciliation(workspaceAccountID: number, shouldUseCon }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`, @@ -937,7 +941,9 @@ function toggleContinuousReconciliation(workspaceAccountID: number, shouldUseCon }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`, @@ -1009,7 +1015,7 @@ function resolveFraudAlert(cardID: number | undefined, isFraud: boolean, reportI const resolution = isFraud ? CONST.CARD_FRAUD_ALERT_RESOLUTION.FRAUD : CONST.CARD_FRAUD_ALERT_RESOLUTION.RECOGNIZED; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1024,7 +1030,7 @@ function resolveFraudAlert(cardID: number | undefined, isFraud: boolean, reportI }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1036,7 +1042,7 @@ function resolveFraudAlert(cardID: number | undefined, isFraud: boolean, reportI }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, diff --git a/src/libs/actions/Travel.ts b/src/libs/actions/Travel.ts index 7f6439ea9b0e3..67567b62577d8 100644 --- a/src/libs/actions/Travel.ts +++ b/src/libs/actions/Travel.ts @@ -11,7 +11,7 @@ import type {Route} from '@src/ROUTES'; * Accept Spotnana terms and conditions to receive a proper token used for authenticating further actions */ function acceptSpotnanaTerms(domain?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.NVP_TRAVEL_SETTINGS, @@ -29,7 +29,7 @@ function acceptSpotnanaTerms(domain?: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.TRAVEL_PROVISIONING, @@ -39,7 +39,7 @@ function acceptSpotnanaTerms(domain?: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.TRAVEL_PROVISIONING, diff --git a/src/libs/actions/VacationDelegate.ts b/src/libs/actions/VacationDelegate.ts index 32cdc7953610b..f66a3fae4966b 100644 --- a/src/libs/actions/VacationDelegate.ts +++ b/src/libs/actions/VacationDelegate.ts @@ -10,7 +10,7 @@ import type {VacationDelegate} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; function setVacationDelegate(creator: string, delegate: string, shouldOverridePolicyDiffWarning = false, currentDelegate?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, @@ -24,7 +24,7 @@ function setVacationDelegate(creator: string, delegate: string, shouldOverridePo }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, @@ -64,7 +64,7 @@ function deleteVacationDelegate(vacationDelegate?: VacationDelegate) { } const {creator, delegate} = vacationDelegate; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, @@ -77,7 +77,7 @@ function deleteVacationDelegate(vacationDelegate?: VacationDelegate) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, From d1ad4d22b582b6d92db2040fec01487cd6a76f39 Mon Sep 17 00:00:00 2001 From: Olgierd Date: Thu, 18 Dec 2025 16:55:15 +0100 Subject: [PATCH 07/10] Run npm run prettier --- src/libs/actions/TeachersUnite.ts | 18 +++++++++++++++--- src/libs/actions/User.ts | 8 ++++++-- src/libs/actions/connections/index.ts | 9 ++++++++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/libs/actions/TeachersUnite.ts b/src/libs/actions/TeachersUnite.ts index 440f5618dadff..11a8f86b45396 100644 --- a/src/libs/actions/TeachersUnite.ts +++ b/src/libs/actions/TeachersUnite.ts @@ -99,7 +99,9 @@ function addSchoolPrincipal( reportActionID: expenseReportCreatedAction.reportActionID, }; - const optimisticData: Array> = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM, @@ -147,7 +149,15 @@ function addSchoolPrincipal( }, ]; - const successData: Array> = [ + const successData: Array< + OnyxUpdate< + | typeof ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM + | typeof ONYXKEYS.COLLECTION.POLICY + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + > + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM, @@ -188,7 +198,9 @@ function addSchoolPrincipal( }, ]; - const failureData: Array> = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM, diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index de3fb556ecc93..b680fa3289b84 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -1104,7 +1104,9 @@ function generateStatementPDF(period: string) { */ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], backTo?: string) { const oldDefaultContactMethod = currentEmail; - const optimisticData: Array> = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1157,7 +1159,9 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN }, }, ]; - const failureData: Array> = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 604022920eee1..4e81b309135d1 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -18,7 +18,14 @@ function removePolicyConnection(policy: Policy, connectionName: PolicyConnection const policyID = policy.id; const workspaceAccountID = policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID; - const optimisticData: Array> = [ + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.POLICY + | typeof ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS + | typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION + | typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION + > + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, From d30fbca9b24ab447e4ef574baf23a1adeb19ea08 Mon Sep 17 00:00:00 2001 From: Olgierd Date: Fri, 19 Dec 2025 22:38:07 +0100 Subject: [PATCH 08/10] Apply improved codegen with better push method usage analysis and empty array handling --- src/libs/ReportUtils.ts | 8 ++- src/libs/actions/Card.ts | 30 ++++---- src/libs/actions/CompanyCards.ts | 31 +++++---- src/libs/actions/IOU.ts | 91 ++++++++++++++++++------- src/libs/actions/PaymentMethods.ts | 2 +- src/libs/actions/Policy/DistanceRate.ts | 4 +- src/libs/actions/Policy/Policy.ts | 4 +- src/libs/actions/Report.ts | 32 ++++++--- src/libs/actions/Search.ts | 14 ++-- src/libs/actions/Session/index.ts | 2 +- src/libs/actions/Transaction.ts | 23 ++++++- src/libs/actions/Travel.ts | 4 +- src/libs/actions/User.ts | 6 +- src/libs/actions/VacationDelegate.ts | 8 +-- src/libs/actions/connections/index.ts | 4 +- 15 files changed, 173 insertions(+), 90 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 462ede3eca9b6..cd70a0710a41c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -10347,9 +10347,11 @@ function getTaskAssigneeChatOnyxData( let optimisticChatCreatedReportAction: OptimisticCreatedReportAction | undefined; const assigneeChatReportMetadata = getReportMetadata(assigneeChatReportID); const currentTime = DateUtils.getDBTime(); - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array> = []; + const successData: Array< + OnyxUpdate + > = []; + const failureData: Array> = []; // You're able to assign a task to someone you haven't chatted with before - so we need to optimistically create the chat and the chat reportActions // Only add the assignee chat report to onyx if we haven't already set it optimistically diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index e8f7aabd20f3a..50abba9e0a4f1 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -47,12 +47,12 @@ type IssueNewCardFlowData = { function reportVirtualExpensifyCardFraud(card: Card, validateCode: string) { const cardID = card?.cardID ?? CONST.DEFAULT_NUMBER_ID; - const optimisticData: OnyxUpdate[] = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, value: { + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 cardID, isLoading: true, errors: null, @@ -65,7 +65,7 @@ function reportVirtualExpensifyCardFraud(card: Card, validateCode: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, @@ -80,7 +80,7 @@ function reportVirtualExpensifyCardFraud(card: Card, validateCode: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, @@ -459,7 +459,7 @@ function updateExpensifyCardLimit( return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -479,7 +479,7 @@ function updateExpensifyCardLimit( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -496,7 +496,7 @@ function updateExpensifyCardLimit( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -533,7 +533,7 @@ function updateExpensifyCardTitle(workspaceAccountID: number, cardID: number, ne return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -551,7 +551,7 @@ function updateExpensifyCardTitle(workspaceAccountID: number, cardID: number, ne }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -567,7 +567,7 @@ function updateExpensifyCardTitle(workspaceAccountID: number, cardID: number, ne }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -601,7 +601,7 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -620,7 +620,7 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -637,7 +637,7 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -673,7 +673,7 @@ function deactivateCard(workspaceAccountID: number, card?: Card) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -690,7 +690,7 @@ function deactivateCard(workspaceAccountID: number, card?: Card) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, diff --git a/src/libs/actions/CompanyCards.ts b/src/libs/actions/CompanyCards.ts index 913208b65e420..1bcf3162403c8 100644 --- a/src/libs/actions/CompanyCards.ts +++ b/src/libs/actions/CompanyCards.ts @@ -223,7 +223,14 @@ function deleteWorkspaceCompanyCardFeed(policyID: string, domainOrWorkspaceAccou const successCardUpdates = Object.fromEntries(cardIDs.map((cardID) => [cardID, null])); const failureCardUpdates = Object.fromEntries(cardIDs.map((cardID) => [cardID, {pendingAction: null}])); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER + | typeof ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST + | typeof ONYXKEYS.CARD_LIST + | typeof ONYXKEYS.COLLECTION.LAST_SELECTED_FEED + > + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -245,7 +252,7 @@ function deleteWorkspaceCompanyCardFeed(policyID: string, domainOrWorkspaceAccou }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -270,7 +277,7 @@ function deleteWorkspaceCompanyCardFeed(policyID: string, domainOrWorkspaceAccou }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -454,7 +461,7 @@ function unassignWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, bankNa function updateWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, cardID: string, bankName: CompanyCardFeed, lastScrapeResult?: number) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -489,7 +496,7 @@ function updateWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, cardID: }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -518,7 +525,7 @@ function updateWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, cardID: }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -564,7 +571,7 @@ function updateWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, cardID: function updateCompanyCardName(domainOrWorkspaceAccountID: number, cardID: string, newCardTitle: string, bankName: CompanyCardFeed, oldCardTitle?: string) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -589,7 +596,7 @@ function updateCompanyCardName(domainOrWorkspaceAccountID: number, cardID: strin }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -604,7 +611,7 @@ function updateCompanyCardName(domainOrWorkspaceAccountID: number, cardID: strin }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -640,7 +647,7 @@ function updateCompanyCardName(domainOrWorkspaceAccountID: number, cardID: strin function setCompanyCardExportAccount(policyID: string, domainOrWorkspaceAccountID: number, cardID: string, accountKey: string, newAccount: string, bank: CompanyCardFeed) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bank}`, @@ -660,7 +667,7 @@ function setCompanyCardExportAccount(policyID: string, domainOrWorkspaceAccountI }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bank}`, @@ -675,7 +682,7 @@ function setCompanyCardExportAccount(policyID: string, domainOrWorkspaceAccountI }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bank}`, diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 5a94465893dc9..4bd91f4e93b2a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1538,7 +1538,7 @@ type BuildOnyxDataForTestDriveIOUParams = { }; function buildOnyxDataForTestDriveIOU(testDriveIOUParams: BuildOnyxDataForTestDriveIOUParams): OnyxData { - const optimisticData: OnyxUpdate[] = []; + const optimisticData: Array> = []; const successData: OnyxUpdate[] = []; const failureData: OnyxUpdate[] = []; @@ -3085,7 +3085,9 @@ function getDeleteTrackExpenseInformation( const {lastMessageText = '', lastMessageHtml = ''} = getLastVisibleMessage(chatReportID, canUserPerformWriteAction, updatedReportAction); // STEP 4: Build Onyx data - const optimisticData: OnyxUpdate[] = []; + const optimisticData: Array< + OnyxUpdate + > = []; if (shouldDeleteTransactionFromOnyx && shouldRemoveIOUTransaction) { optimisticData.push({ @@ -3176,7 +3178,9 @@ function getDeleteTrackExpenseInformation( }); } - const failureData: OnyxUpdate[] = []; + const failureData: Array< + OnyxUpdate + > = []; if (shouldDeleteTransactionFromOnyx && shouldRemoveIOUTransaction) { failureData.push({ @@ -4382,8 +4386,19 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U isASAPSubmitBetaEnabled, } = params; const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const successData: Array< + OnyxUpdate + > = []; + const failureData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + | typeof ONYXKEYS.COLLECTION.SNAPSHOT + | typeof ONYXKEYS.COLLECTION.NEXT_STEP + > + > = []; // Step 1: Set any "pending fields" (ones updated while the user was offline) to have error messages in the failureData const pendingFields: OnyxTypes.Transaction['pendingFields'] = Object.fromEntries(Object.keys(transactionChanges).map((key) => [key, CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE])); @@ -4869,9 +4884,9 @@ function getUpdateTrackExpenseParams( policy: OnyxEntry, shouldBuildOptimisticModifiedExpenseReportAction = true, ): UpdateMoneyRequestData { - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array> = []; + const successData: Array> = []; + const failureData: Array> = []; // Step 1: Set any "pending fields" (ones updated while the user was offline) to have error messages in the failureData const pendingFields = Object.fromEntries(Object.keys(transactionChanges).map((key) => [key, CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE])); @@ -8958,7 +8973,7 @@ function cleanUpMoneyRequest( // build Onyx data // Onyx operations to delete the transaction, update the IOU report action and chat report action - const reportActionsOnyxUpdates: OnyxUpdate[] = []; + const reportActionsOnyxUpdates: Array> = []; const onyxUpdates: Array< OnyxUpdate > = [ @@ -9713,7 +9728,15 @@ function getSendMoneyParams({ }, ]; - const successData: OnyxUpdate[] = []; + const successData: Array< + OnyxUpdate< + | typeof ONYXKEYS.PERSONAL_DETAILS_LIST + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION + > + > = []; // Add optimistic personal details for recipient let optimisticPersonalDetailListData: OnyxUpdate | null = null; @@ -10063,7 +10086,7 @@ function getReportFromHoldRequestsOnyxData( }; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, @@ -10143,7 +10166,7 @@ function getReportFromHoldRequestsOnyxData( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, @@ -11600,7 +11623,7 @@ function submitReport( }); } - const successData: OnyxUpdate[] = []; + const successData: Array> = []; successData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, @@ -12181,7 +12204,7 @@ function replaceReceipt({transactionID, file, source, transactionPolicy, transac }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12193,7 +12216,7 @@ function replaceReceipt({transactionID, file, source, transactionPolicy, transac }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12240,10 +12263,10 @@ function replaceReceipt({transactionID, file, source, transactionPolicy, transac }, }); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${currentSearchQueryJSON.hash}`, + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 value: { data: { [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { @@ -13004,7 +13027,7 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread const optimisticData: OnyxUpdate[] = []; const failureData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; + const successData: Array> = []; optimisticData.push( optimisticTransactionData, @@ -13169,11 +13192,11 @@ function resolveDuplicates(params: MergeDuplicatesParams) { }) .filter((id): id is string => !!id); - const optimisticHoldActions: OnyxUpdate[] = []; - const failureHoldActions: OnyxUpdate[] = []; + const optimisticHoldActions: Array> = []; + const failureHoldActions: Array> = []; const reportActionIDList: string[] = []; - const optimisticHoldTransactionActions: OnyxUpdate[] = []; - const failureHoldTransactionActions: OnyxUpdate[] = []; + const optimisticHoldTransactionActions: Array> = []; + const failureHoldTransactionActions: Array> = []; for (const action of iouActionList) { const transactionThreadReportID = action?.childReportID; const createdReportAction = buildOptimisticHoldReportAction(); @@ -13492,7 +13515,16 @@ function prepareRejectMoneyRequestData( })(); // Build optimistic data updates - const optimisticData: OnyxUpdate[] = []; + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + > + > = []; // Create system messages in both expense report and expense thread // The "rejected this expense" action should come before the reject comment @@ -13502,8 +13534,19 @@ function prepareRejectMoneyRequestData( let movedTransactionAction; // Build successData and failureData to prevent duplication - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const successData: Array< + OnyxUpdate + > = []; + const failureData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + > + > = []; if ((!isPolicyDelayedSubmissionEnabled || isIOU) && !shouldUseBulkAction) { if (hasMultipleExpenses) { diff --git a/src/libs/actions/PaymentMethods.ts b/src/libs/actions/PaymentMethods.ts index 4924ebb1ad9a6..c0055ae915731 100644 --- a/src/libs/actions/PaymentMethods.ts +++ b/src/libs/actions/PaymentMethods.ts @@ -468,7 +468,7 @@ function deletePaymentCard(fundID: number) { fundID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.FUND_LIST}`, diff --git a/src/libs/actions/Policy/DistanceRate.ts b/src/libs/actions/Policy/DistanceRate.ts index e210f90849620..b95b6e3cb3036 100644 --- a/src/libs/actions/Policy/DistanceRate.ts +++ b/src/libs/actions/Policy/DistanceRate.ts @@ -441,8 +441,8 @@ function deletePolicyDistanceRates( }, ]; - const optimisticTransactionsViolations: OnyxUpdate[] = []; - const failureTransactionsViolations: OnyxUpdate[] = []; + const optimisticTransactionsViolations: Array> = []; + const failureTransactionsViolations: Array> = []; for (const transactionID of transactionIDsAffected) { const currentTransactionViolations = transactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? []; diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 39af2c12b0546..79fb3750128a2 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -3715,7 +3715,9 @@ function createWorkspaceFromIOUPayment( ]; successData.push(...employeeWorkspaceChat.onyxSuccessData); - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`, diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index b230ab4ec6cb5..ba0e56844a547 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1060,7 +1060,7 @@ function openReport( }); } - const finallyData: OnyxUpdate[] = []; + const finallyData: Array> = []; const parameters: OpenReportParams = { reportID, @@ -3771,7 +3771,7 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal }, ]; - const successData: OnyxUpdate[] = []; + const successData: Array> = []; if (isWorkspaceMemberLeavingWorkspaceRoom || isChatThread) { successData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -4931,9 +4931,19 @@ function deleteAppReport(reportID: string | undefined, currentUserEmailParam: st Log.warn('[Report] deleteReport called with no reportID'); return; } - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + > + > = []; + const successData: Array> = []; + const failureData: Array< + OnyxUpdate + > = []; const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; @@ -5457,9 +5467,9 @@ function moveIOUReportToPolicyAndInviteSubmitter( } function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, policyID: string, optimisticPolicyExpenseChatReportID: string) { - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array> = []; + const successData: Array> = []; + const failureData: Array> = []; const expenseReport = { ...iouReport, @@ -5706,8 +5716,10 @@ function buildOptimisticChangePolicyData( optimisticPolicyExpenseChatReport?: Report, ) { const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const successData: Array> = []; + const failureData: Array< + OnyxUpdate + > = []; // 1. Optimistically set the policyID on the report (and all its threads) by: // 1.1 Preprocess reports to create a map of parentReportID to child reports list of reportIDs diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 44735b53ad44a..973c1cb1b16f5 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -273,7 +273,7 @@ function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: const saveSearchName = newName ?? queryJSON?.inputQuery ?? ''; const jsonQuery = JSON.stringify(queryJSON); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -287,7 +287,7 @@ function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -297,7 +297,7 @@ function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -312,7 +312,7 @@ function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: } function deleteSavedSearch(hash: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -323,7 +323,7 @@ function deleteSavedSearch(hash: number) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -332,7 +332,7 @@ function deleteSavedSearch(hash: number) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -1154,7 +1154,7 @@ function setOptimisticDataForTransactionThreadPreview(item: TransactionListItemT const {reportID, report, amount, currency, transactionID, created, policyID} = item; const moneyRequestReportActionID = item?.reportAction?.reportActionID; const {hasParentReport, hasParentReportAction, hasTransaction, hasTransactionThreadReport} = transactionPreviewData; - const onyxUpdates: OnyxUpdate[] = []; + const onyxUpdates: Array> = []; // Set optimistic parent report if (!hasParentReport) { diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index b71b9c86a79b7..69a79d257c858 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -189,7 +189,7 @@ function getShortLivedLoginParams(isSupportAuthTokenUsed = false, isSAML = false }, ]; - const failureData: OnyxUpdate[] = []; + const failureData: Array> = []; if (CONFIG.IS_HYBRID_APP && isSAML) { optimisticData.push({ diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index ba978af8c75eb..c370d461a22c5 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -717,8 +717,25 @@ function changeTransactionsReport( } const optimisticData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; + const failureData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + | typeof ONYXKEYS.COLLECTION.NEXT_STEP + > + > = []; + const successData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + > + > = []; const existingSelfDMReportID = findSelfDMReportID(); let selfDMReport: Report | undefined; @@ -1074,9 +1091,9 @@ function changeTransactionsReport( failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${oldIOUAction.childReportID}`, + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 value: { parentReportID: isUnreportedExpense ? selfDMReportID : oldReportID, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 optimisticMoneyRequestReportActionID: oldIOUAction.reportActionID, policyID: allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oldIOUAction.reportActionID}`]?.policyID, }, diff --git a/src/libs/actions/Travel.ts b/src/libs/actions/Travel.ts index 67567b62577d8..ea38a7163a6c9 100644 --- a/src/libs/actions/Travel.ts +++ b/src/libs/actions/Travel.ts @@ -59,12 +59,12 @@ function acceptSpotnanaTerms(domain?: string) { } function requestTravelAccess() { - const optimisticData: OnyxUpdate[] = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + const optimisticData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.NVP_TRAVEL_SETTINGS, value: { + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 lastTravelSignupRequestTime: Date.now(), }, }, diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index b680fa3289b84..fba3ecffe555c 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -1476,9 +1476,9 @@ type RespondToProactiveAppReviewParams = { */ function respondToProactiveAppReview(response: 'positive' | 'negative' | 'skip', currentProactiveAppReview: AppReview | null | undefined, message?: string, conciergeChatReportID?: string) { const params: RespondToProactiveAppReviewParams = {response}; - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array> = []; + const successData: Array> = []; + const failureData: Array> = []; // Capture current values for failure data const originalResponse = currentProactiveAppReview?.response; diff --git a/src/libs/actions/VacationDelegate.ts b/src/libs/actions/VacationDelegate.ts index f66a3fae4966b..320e7edbf4e57 100644 --- a/src/libs/actions/VacationDelegate.ts +++ b/src/libs/actions/VacationDelegate.ts @@ -36,12 +36,12 @@ function setVacationDelegate(creator: string, delegate: string, shouldOverridePo }, ]; - const failureData: OnyxUpdate[] = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, value: { + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 errors: ErrorUtils.getMicroSecondTranslationErrorWithTranslationKey('statusPage.vacationDelegateError'), }, }, @@ -88,14 +88,14 @@ function deleteVacationDelegate(vacationDelegate?: VacationDelegate) { }, ]; - const failureData: OnyxUpdate[] = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, value: { creator, delegate, + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 errors: ErrorUtils.getMicroSecondTranslationErrorWithTranslationKey('statusPage.vacationDelegateError'), }, }, diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 4e81b309135d1..8d123a0de3163 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -52,8 +52,8 @@ function removePolicyConnection(policy: Policy, connectionName: PolicyConnection }, ]; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const successData: Array> = []; + const failureData: Array> = []; const supportedConnections: PolicyConnectionName[] = [CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.POLICY.CONNECTIONS.NAME.XERO]; if (PolicyUtils.isCollectPolicy(policy) && supportedConnections.includes(connectionName)) { From d52bd38efbd57e59db50d4a45e4faa5baef29a2a Mon Sep 17 00:00:00 2001 From: Olgierd Date: Mon, 22 Dec 2025 07:36:56 +0100 Subject: [PATCH 09/10] Apply codegen to tsx files --- src/libs/actions/UnreportedExpenses.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/UnreportedExpenses.tsx b/src/libs/actions/UnreportedExpenses.tsx index cf26795048904..f24ff0695561c 100644 --- a/src/libs/actions/UnreportedExpenses.tsx +++ b/src/libs/actions/UnreportedExpenses.tsx @@ -5,7 +5,7 @@ import {READ_COMMANDS} from '@libs/API/types'; import ONYXKEYS from '@src/ONYXKEYS'; function fetchUnreportedExpenses(offset: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_UNREPORTED_TRANSACTIONS, @@ -13,7 +13,7 @@ function fetchUnreportedExpenses(offset: number) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_UNREPORTED_TRANSACTIONS, @@ -21,7 +21,7 @@ function fetchUnreportedExpenses(offset: number) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_UNREPORTED_TRANSACTIONS, From 75ab0cdde98b6f09daf9cc9a5ece3b6a08f18a6c Mon Sep 17 00:00:00 2001 From: Olgierd Date: Mon, 22 Dec 2025 07:46:47 +0100 Subject: [PATCH 10/10] Apply codegen to files from ./tests --- tests/actions/QueuedOnyxUpdatesTest.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/actions/QueuedOnyxUpdatesTest.ts b/tests/actions/QueuedOnyxUpdatesTest.ts index b0f5a2b384473..d9959d31f6d4c 100644 --- a/tests/actions/QueuedOnyxUpdatesTest.ts +++ b/tests/actions/QueuedOnyxUpdatesTest.ts @@ -5,7 +5,19 @@ import type {OnyxKey} from '@src/ONYXKEYS'; import ONYXKEYS from '@src/ONYXKEYS'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; -const queuedOnyxUpdates: OnyxUpdate[] = [ +const queuedOnyxUpdates: Array< + OnyxUpdate< + | typeof ONYXKEYS.NVP_TRY_FOCUS_MODE + | typeof ONYXKEYS.PREFERRED_THEME + | typeof ONYXKEYS.NVP_PREFERRED_LOCALE + | typeof ONYXKEYS.SESSION + | typeof ONYXKEYS.IS_LOADING_APP + | typeof ONYXKEYS.CREDENTIALS + | typeof ONYXKEYS.IS_SIDEBAR_LOADED + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + > +> = [ {key: ONYXKEYS.NVP_TRY_FOCUS_MODE, value: true, onyxMethod: 'merge'}, {key: ONYXKEYS.PREFERRED_THEME, value: 'system', onyxMethod: 'merge'}, {key: ONYXKEYS.NVP_PREFERRED_LOCALE, value: 'en', onyxMethod: 'merge'},