From 022a517f8318e0965d2c9bcbc35ea92a51ba1c21 Mon Sep 17 00:00:00 2001 From: gelocraft Date: Mon, 1 Dec 2025 03:13:59 +0000 Subject: [PATCH 1/6] chore(eslint): remove inline disables --- src/libs/actions/Policy/Policy.ts | 8 -------- src/libs/actions/Search.ts | 4 ---- src/libs/actions/User.ts | 4 ---- .../utils/getSignerDetailsAndSignerFiles.ts | 1 - .../NonUSD/BankInfo/subSteps/BankAccountDetails.tsx | 2 -- 5 files changed, 19 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index d9e2a7b6f3f7..cae586ba9d1d 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -486,7 +486,6 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { const finallyData: OnyxUpdate[] = []; const currentTime = DateUtils.getDBTime(); - // eslint-disable-next-line unicorn/no-array-for-each reportsToArchive.forEach((report) => { const {reportID, ownerAccountID, oldPolicyName} = report ?? {}; const isInvoiceReceiverReport = report?.invoiceReceiver && 'policyID' in report.invoiceReceiver && report.invoiceReceiver.policyID === policyID; @@ -578,7 +577,6 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { } }); - // eslint-disable-next-line unicorn/no-array-for-each Object.keys(lastUsedPaymentMethods ?? {})?.forEach((paymentMethodKey) => { const lastUsedPaymentMethod = lastUsedPaymentMethods?.[paymentMethodKey]; @@ -1086,7 +1084,6 @@ function leaveWorkspace(policyID?: string) { const currentTime = DateUtils.getDBTime(); const pendingChatMembers = ReportUtils.getPendingChatMembers([deprecatedSessionAccountID], [], CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); - // eslint-disable-next-line unicorn/no-array-for-each workspaceChats.forEach((report) => { const parentReport = ReportUtils.getRootParentReport({report}); const reportToCheckOwner = isEmptyObject(parentReport) ? report : parentReport; @@ -1302,7 +1299,6 @@ function createPolicyExpenseChats( reportCreationData: {}, }; - // eslint-disable-next-line unicorn/no-array-for-each Object.keys(invitedEmailsToAccountIDs).forEach((email) => { const accountID = invitedEmailsToAccountIDs[email]; const cleanAccountID = Number(accountID); @@ -1333,7 +1329,6 @@ function createPolicyExpenseChats( }); const currentTime = DateUtils.getDBTime(); const reportActions = deprecatedAllReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${oldChat.reportID}`] ?? {}; - // eslint-disable-next-line unicorn/no-array-for-each Object.values(reportActions).forEach((action) => { if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) { return; @@ -2425,7 +2420,6 @@ function buildPolicyData(options: BuildPolicyDataOptions = {}) { if (getAdminPolicies().length === 0 && lastUsedPaymentMethod) { Object.values(deprecatedAllReports ?? {}) .filter((iouReport) => iouReport?.type === CONST.REPORT.TYPE.IOU) - // eslint-disable-next-line unicorn/no-array-for-each .forEach((iouReport) => { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing if (lastUsedPaymentMethod?.iou?.name || !iouReport?.policyID) { @@ -3771,7 +3765,6 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry): WorkspaceF // For performance reasons, we are going to compose a merge collection data for transactions const transactionsOptimisticData: Record = {}; const transactionFailureData: Record = {}; - // eslint-disable-next-line unicorn/no-array-for-each reportTransactions.forEach((transaction) => { transactionsOptimisticData[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = { ...transaction, @@ -6200,7 +6193,6 @@ function clearAllPolicies() { if (!deprecatedAllPolicies) { return; } - // eslint-disable-next-line unicorn/no-array-for-each Object.keys(deprecatedAllPolicies).forEach((key) => delete deprecatedAllPolicies[key]); } diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 1ba7b10611c3..55cef5f2d6ca 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -421,7 +421,6 @@ function search({ function holdMoneyRequestOnSearch(hash: number, transactionIDList: string[], comment: string, allTransactions: OnyxCollection, allReportActions: OnyxCollection) { const {optimisticData, finallyData} = getOnyxLoadingData(hash); - // eslint-disable-next-line unicorn/no-array-for-each transactionIDList.forEach((transactionID) => { const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]; const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transaction?.reportID}`] ?? {}; @@ -793,7 +792,6 @@ type Params = Record; function exportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDList}: ExportSearchItemsToCSVParams, onDownloadFailed: () => void) { const reportIDListParams: string[] = []; - // eslint-disable-next-line unicorn/no-array-for-each reportIDList.forEach((reportID) => { const allReportTransactions = getReportTransactions(reportID).filter((transaction) => transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); const allTransactionIDs = allReportTransactions.map((transaction) => transaction.transactionID); @@ -812,7 +810,6 @@ function exportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDLi }) as Params; const formData = new FormData(); - // eslint-disable-next-line unicorn/no-array-for-each Object.entries(finalParameters).forEach(([key, value]) => { if (Array.isArray(value)) { formData.append(key, value.join(',')); @@ -922,7 +919,6 @@ function clearAdvancedFilters() { const values: Partial> = {}; Object.values(FILTER_KEYS) .filter((key) => key !== FILTER_KEYS.GROUP_BY) - // eslint-disable-next-line unicorn/no-array-for-each .forEach((key) => { if (key === FILTER_KEYS.TYPE) { values[key] = CONST.SEARCH.DATA_TYPES.EXPENSE; diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index b2d6a8a32c43..bc151e76db67 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -568,7 +568,6 @@ function validateSecondaryLogin( ], ); - // eslint-disable-next-line unicorn/no-array-for-each Object.values(allPolicies ?? {}).forEach((policy) => { if (!policy) { return; @@ -662,7 +661,6 @@ function isBlockedFromConcierge(blockedFromConciergeNVP: OnyxEntry { if (!update.shouldNotify && !update.shouldShowPushNotification) { return; @@ -671,7 +669,6 @@ function triggerNotifications(onyxUpdates: OnyxServerUpdate[]) { const reportID = update.key.replace(ONYXKEYS.COLLECTION.REPORT_ACTIONS, ''); const reportActions = Object.values((update.value as OnyxCollection) ?? {}); - // eslint-disable-next-line unicorn/no-array-for-each reportActions.forEach((action) => action && showReportActionNotification(reportID, action)); }); } @@ -1211,7 +1208,6 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN }, ]; - // eslint-disable-next-line unicorn/no-array-for-each Object.values(allPolicies ?? {}).forEach((policy) => { if (!policy) { return; diff --git a/src/pages/ReimbursementAccount/EnterSignerInfo/utils/getSignerDetailsAndSignerFiles.ts b/src/pages/ReimbursementAccount/EnterSignerInfo/utils/getSignerDetailsAndSignerFiles.ts index bc57c51ce4b9..698aeb09a739 100644 --- a/src/pages/ReimbursementAccount/EnterSignerInfo/utils/getSignerDetailsAndSignerFiles.ts +++ b/src/pages/ReimbursementAccount/EnterSignerInfo/utils/getSignerDetailsAndSignerFiles.ts @@ -21,7 +21,6 @@ function getSignerDetailsAndSignerFilesForSignerInfo(enterSignerInfoFormDraft: O const signerDetails: Record = {}; const signerFiles: Record = {}; - // eslint-disable-next-line unicorn/no-array-for-each signerDetailsFields.forEach((fieldName: keyof EnterSignerInfoForm) => { if (fieldName === INPUT_IDS.SIGNER_EMAIL) { signerDetails[fieldName] = signerEmail; diff --git a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx index 424ca05de196..d7888b51cb2d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx @@ -56,7 +56,6 @@ function BankAccountDetails({onNext, isEditing, corpayFields}: BankInfoSubStepPr (values: FormOnyxValues): FormInputErrors => { const errors: FormInputErrors = {}; - // eslint-disable-next-line unicorn/no-array-for-each corpayFields?.formFields?.forEach((field) => { const fieldID = field.id as keyof FormOnyxValues; @@ -64,7 +63,6 @@ function BankAccountDetails({onNext, isEditing, corpayFields}: BankInfoSubStepPr errors[fieldID] = translate('common.error.fieldRequired'); } - // eslint-disable-next-line unicorn/no-array-for-each field.validationRules.forEach((rule) => { if (!rule.regEx) { return; From b9d4f7eb471e9585fa2df4720fb377cb4eb745c1 Mon Sep 17 00:00:00 2001 From: gelocraft Date: Mon, 1 Dec 2025 03:44:16 +0000 Subject: [PATCH 2/6] fix(eslint): auto-fix unicorn/no-array-for-each rule violations --- src/libs/actions/Policy/Policy.ts | 66 +++++++++---------- src/libs/actions/Search.ts | 38 +++++------ src/libs/actions/User.ts | 22 ++++--- .../BankInfo/subSteps/BankAccountDetails.tsx | 34 +++++----- 4 files changed, 81 insertions(+), 79 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index cae586ba9d1d..6ed52c434132 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -486,7 +486,7 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { const finallyData: OnyxUpdate[] = []; const currentTime = DateUtils.getDBTime(); - reportsToArchive.forEach((report) => { + for (const report of reportsToArchive) { const {reportID, ownerAccountID, oldPolicyName} = report ?? {}; const isInvoiceReceiverReport = report?.invoiceReceiver && 'policyID' in report.invoiceReceiver && report.invoiceReceiver.policyID === policyID; optimisticData.push({ @@ -575,7 +575,7 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { value: transactionViolation, }); } - }); + } Object.keys(lastUsedPaymentMethods ?? {})?.forEach((paymentMethodKey) => { const lastUsedPaymentMethod = lastUsedPaymentMethods?.[paymentMethodKey]; @@ -1084,12 +1084,12 @@ function leaveWorkspace(policyID?: string) { const currentTime = DateUtils.getDBTime(); const pendingChatMembers = ReportUtils.getPendingChatMembers([deprecatedSessionAccountID], [], CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); - workspaceChats.forEach((report) => { + for (const report of workspaceChats) { const parentReport = ReportUtils.getRootParentReport({report}); const reportToCheckOwner = isEmptyObject(parentReport) ? report : parentReport; if (ReportUtils.isPolicyExpenseChat(report) && !ReportUtils.isReportOwner(reportToCheckOwner)) { - return; + continue; } optimisticData.push( @@ -1141,7 +1141,7 @@ function leaveWorkspace(policyID?: string) { pendingChatMembers: null, }, }); - }); + } const params: LeavePolicyParams = { policyID, @@ -1299,7 +1299,7 @@ function createPolicyExpenseChats( reportCreationData: {}, }; - Object.keys(invitedEmailsToAccountIDs).forEach((email) => { + for (const email of Object.keys(invitedEmailsToAccountIDs)) { const accountID = invitedEmailsToAccountIDs[email]; const cleanAccountID = Number(accountID); const login = PhoneNumber.addSMSDomainIfPhoneNumber(email); @@ -1329,9 +1329,9 @@ function createPolicyExpenseChats( }); const currentTime = DateUtils.getDBTime(); const reportActions = deprecatedAllReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${oldChat.reportID}`] ?? {}; - Object.values(reportActions).forEach((action) => { + for (const action of Object.values(reportActions)) { if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) { - return; + continue; } workspaceMembersChats.onyxOptimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -1347,8 +1347,8 @@ function createPolicyExpenseChats( private_isArchived: currentTime, }, }); - }); - return; + } + continue; } const optimisticReport = ReportUtils.buildOptimisticChatReport({ participantList: [deprecatedSessionAccountID, cleanAccountID], @@ -1452,7 +1452,7 @@ function createPolicyExpenseChats( }, }, }); - }); + } return workspaceMembersChats; } @@ -2418,29 +2418,27 @@ function buildPolicyData(options: BuildPolicyDataOptions = {}) { } if (getAdminPolicies().length === 0 && lastUsedPaymentMethod) { - Object.values(deprecatedAllReports ?? {}) - .filter((iouReport) => iouReport?.type === CONST.REPORT.TYPE.IOU) - .forEach((iouReport) => { - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (lastUsedPaymentMethod?.iou?.name || !iouReport?.policyID) { - return; - } + for (const iouReport of Object.values(deprecatedAllReports ?? {}).filter((iouReport) => iouReport?.type === CONST.REPORT.TYPE.IOU)) { + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + if (lastUsedPaymentMethod?.iou?.name || !iouReport?.policyID) { + continue; + } - successData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_LAST_PAYMENT_METHOD, - value: { - [iouReport?.policyID]: { - iou: { - name: policyID, - }, - lastUsed: { - name: policyID, - }, + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.NVP_LAST_PAYMENT_METHOD, + value: { + [iouReport?.policyID]: { + iou: { + name: policyID, + }, + lastUsed: { + name: policyID, }, }, - }); + }, }); + } } // We need to clone the file to prevent non-indexable errors. @@ -3765,7 +3763,7 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry): WorkspaceF // For performance reasons, we are going to compose a merge collection data for transactions const transactionsOptimisticData: Record = {}; const transactionFailureData: Record = {}; - reportTransactions.forEach((transaction) => { + for (const transaction of reportTransactions) { transactionsOptimisticData[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = { ...transaction, amount: -transaction.amount, @@ -3773,7 +3771,7 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry): WorkspaceF }; transactionFailureData[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = transaction; - }); + } optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE_COLLECTION, @@ -6193,7 +6191,9 @@ function clearAllPolicies() { if (!deprecatedAllPolicies) { return; } - Object.keys(deprecatedAllPolicies).forEach((key) => delete deprecatedAllPolicies[key]); + for (const key of Object.keys(deprecatedAllPolicies)) { + delete deprecatedAllPolicies[key]; + } } function updateInvoiceCompanyName(policyID: string, companyName: string) { diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 55cef5f2d6ca..8f991b44bef3 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -421,7 +421,7 @@ function search({ function holdMoneyRequestOnSearch(hash: number, transactionIDList: string[], comment: string, allTransactions: OnyxCollection, allReportActions: OnyxCollection) { const {optimisticData, finallyData} = getOnyxLoadingData(hash); - transactionIDList.forEach((transactionID) => { + for (const transactionID of transactionIDList) { const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]; const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transaction?.reportID}`] ?? {}; const iouReportAction = getIOUActionForTransactionID(Object.values(reportActions ?? {}), transactionID); @@ -436,7 +436,7 @@ function holdMoneyRequestOnSearch(hash: number, transactionIDList: string[], com }, }); } - }); + } API.write(WRITE_COMMANDS.HOLD_MONEY_REQUEST_ON_SEARCH, {hash, transactionIDList, comment}, {optimisticData, finallyData}); } @@ -792,16 +792,16 @@ type Params = Record; function exportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDList}: ExportSearchItemsToCSVParams, onDownloadFailed: () => void) { const reportIDListParams: string[] = []; - reportIDList.forEach((reportID) => { + for (const reportID of reportIDList) { const allReportTransactions = getReportTransactions(reportID).filter((transaction) => transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); const allTransactionIDs = allReportTransactions.map((transaction) => transaction.transactionID); if (allTransactionIDs.every((transactionID) => transactionIDList.includes(transactionID))) { if (reportIDListParams.includes(reportID)) { - return; + continue; } reportIDListParams.push(reportID); } - }); + } const finalParameters = enhanceParameters(WRITE_COMMANDS.EXPORT_SEARCH_ITEMS_TO_CSV, { query, jsonQuery, @@ -810,13 +810,13 @@ function exportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDLi }) as Params; const formData = new FormData(); - Object.entries(finalParameters).forEach(([key, value]) => { + for (const [key, value] of Object.entries(finalParameters)) { if (Array.isArray(value)) { formData.append(key, value.join(',')); } else { formData.append(key, SafeString(value)); } - }); + } fileDownload(getCommandURL({command: WRITE_COMMANDS.EXPORT_SEARCH_ITEMS_TO_CSV}), 'Expensify.csv', '', false, formData, CONST.NETWORK.METHOD.POST, onDownloadFailed); } @@ -917,21 +917,19 @@ function clearAllFilters() { function clearAdvancedFilters() { const values: Partial> = {}; - Object.values(FILTER_KEYS) - .filter((key) => key !== FILTER_KEYS.GROUP_BY) - .forEach((key) => { - if (key === FILTER_KEYS.TYPE) { - values[key] = CONST.SEARCH.DATA_TYPES.EXPENSE; - return; - } + for (const key of Object.values(FILTER_KEYS).filter((key) => key !== FILTER_KEYS.GROUP_BY)) { + if (key === FILTER_KEYS.TYPE) { + values[key] = CONST.SEARCH.DATA_TYPES.EXPENSE; + continue; + } - if (key === FILTER_KEYS.STATUS) { - values[key] = CONST.SEARCH.STATUS.EXPENSE.ALL; - return; - } + if (key === FILTER_KEYS.STATUS) { + values[key] = CONST.SEARCH.STATUS.EXPENSE.ALL; + continue; + } - values[key] = null; - }); + values[key] = null; + } Onyx.merge(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, values); } diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index bc151e76db67..ec89dc99cafa 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -568,9 +568,9 @@ function validateSecondaryLogin( ], ); - Object.values(allPolicies ?? {}).forEach((policy) => { + for (const policy of Object.values(allPolicies ?? {})) { if (!policy) { - return; + continue; } let optimisticPolicyDataValue; @@ -599,7 +599,7 @@ function validateSecondaryLogin( value: optimisticPolicyDataValue, }); } - }); + } } const failureData: OnyxUpdate[] = [ @@ -661,16 +661,18 @@ function isBlockedFromConcierge(blockedFromConciergeNVP: OnyxEntry { + for (const update of onyxUpdates) { if (!update.shouldNotify && !update.shouldShowPushNotification) { - return; + continue; } const reportID = update.key.replace(ONYXKEYS.COLLECTION.REPORT_ACTIONS, ''); const reportActions = Object.values((update.value as OnyxCollection) ?? {}); - reportActions.forEach((action) => action && showReportActionNotification(reportID, action)); - }); + for (const action of reportActions) { + action && showReportActionNotification(reportID, action); + } + } } const isChannelMuted = (reportId: string) => @@ -1208,9 +1210,9 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN }, ]; - Object.values(allPolicies ?? {}).forEach((policy) => { + for (const policy of Object.values(allPolicies ?? {})) { if (!policy) { - return; + continue; } let optimisticPolicyDataValue; @@ -1255,7 +1257,7 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN value: failurePolicyDataValue, }); } - }); + } const parameters: SetContactMethodAsDefaultParams = { partnerUserID: newDefaultContactMethod, }; diff --git a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx index d7888b51cb2d..23eae2db2686 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx @@ -56,29 +56,31 @@ function BankAccountDetails({onNext, isEditing, corpayFields}: BankInfoSubStepPr (values: FormOnyxValues): FormInputErrors => { const errors: FormInputErrors = {}; - corpayFields?.formFields?.forEach((field) => { - const fieldID = field.id as keyof FormOnyxValues; + if (corpayFields?.formFields) { + for (const field of corpayFields.formFields) { + const fieldID = field.id as keyof FormOnyxValues; - if (field.isRequired && !values[fieldID]) { - errors[fieldID] = translate('common.error.fieldRequired'); - } - - field.validationRules.forEach((rule) => { - if (!rule.regEx) { - return; + if (field.isRequired && !values[fieldID]) { + errors[fieldID] = translate('common.error.fieldRequired'); } - if (new RegExp(rule.regEx).test(SafeString(values[fieldID]))) { - return; - } + for (const rule of field.validationRules) { + if (!rule.regEx) { + continue; + } + + if (new RegExp(rule.regEx).test(SafeString(values[fieldID]))) { + continue; + } - errors[fieldID] = rule.errorMessage; - }); - }); + errors[fieldID] = rule.errorMessage; + } + } + } return errors; }, - [corpayFields, translate], + [corpayFields?.formFields, translate], ); const handleSubmit = useReimbursementAccountStepFormSubmit({ From f2deed3f0ea7976a64a007b0610cbfc9adeb200e Mon Sep 17 00:00:00 2001 From: gelocraft Date: Mon, 1 Dec 2025 09:28:09 +0000 Subject: [PATCH 3/6] fix(eslint): @typescript-eslint/no-unused-expressions --- src/libs/actions/User.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index ec89dc99cafa..be0d271da85a 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -670,7 +670,9 @@ function triggerNotifications(onyxUpdates: OnyxServerUpdate[]) { const reportActions = Object.values((update.value as OnyxCollection) ?? {}); for (const action of reportActions) { - action && showReportActionNotification(reportID, action); + if (action) { + showReportActionNotification(reportID, action); + } } } } From 243bb74db7de638dce6b6f65041fb3b6e03cfdae Mon Sep 17 00:00:00 2001 From: gelocraft Date: Mon, 1 Dec 2025 09:38:36 +0000 Subject: [PATCH 4/6] fix(eslint): @typescript-eslint/no-shadow --- src/libs/actions/Policy/Policy.ts | 3 ++- src/libs/actions/Search.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 6ed52c434132..14514d1173e3 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -2418,7 +2418,8 @@ function buildPolicyData(options: BuildPolicyDataOptions = {}) { } if (getAdminPolicies().length === 0 && lastUsedPaymentMethod) { - for (const iouReport of Object.values(deprecatedAllReports ?? {}).filter((iouReport) => iouReport?.type === CONST.REPORT.TYPE.IOU)) { + const iouReports = Object.values(deprecatedAllReports ?? {}).filter((iouReport) => iouReport?.type === CONST.REPORT.TYPE.IOU); + for (const iouReport of iouReports) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing if (lastUsedPaymentMethod?.iou?.name || !iouReport?.policyID) { continue; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 8f991b44bef3..eee9b20d4b59 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -917,7 +917,8 @@ function clearAllFilters() { function clearAdvancedFilters() { const values: Partial> = {}; - for (const key of Object.values(FILTER_KEYS).filter((key) => key !== FILTER_KEYS.GROUP_BY)) { + const filterKeys = Object.values(FILTER_KEYS).filter((key) => key !== FILTER_KEYS.GROUP_BY); + for (const key of filterKeys) { if (key === FILTER_KEYS.TYPE) { values[key] = CONST.SEARCH.DATA_TYPES.EXPENSE; continue; From 6f0331422b584bda7915241d66dfc133ad69543f Mon Sep 17 00:00:00 2001 From: gelocraft Date: Mon, 1 Dec 2025 09:55:01 +0000 Subject: [PATCH 5/6] fix(eslint): manually fix non auto-fixable unicorn/no-array-for-each violations --- src/libs/actions/Policy/Policy.ts | 7 +++---- .../utils/getSignerDetailsAndSignerFiles.ts | 10 +++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 14514d1173e3..abc46ccaac87 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -577,11 +577,11 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { } } - Object.keys(lastUsedPaymentMethods ?? {})?.forEach((paymentMethodKey) => { + for (const paymentMethodKey of Object.keys(lastUsedPaymentMethods ?? {})) { const lastUsedPaymentMethod = lastUsedPaymentMethods?.[paymentMethodKey]; if (typeof lastUsedPaymentMethod === 'string' || !lastUsedPaymentMethod) { - return; + continue; } if (lastUsedPaymentMethod?.iou?.name === policyID) { @@ -615,8 +615,7 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { }, }); } - }); - + } const apiParams: DeleteWorkspaceParams = {policyID}; API.write(WRITE_COMMANDS.DELETE_WORKSPACE, apiParams, {optimisticData, finallyData, failureData}); diff --git a/src/pages/ReimbursementAccount/EnterSignerInfo/utils/getSignerDetailsAndSignerFiles.ts b/src/pages/ReimbursementAccount/EnterSignerInfo/utils/getSignerDetailsAndSignerFiles.ts index 698aeb09a739..ffd54df004e5 100644 --- a/src/pages/ReimbursementAccount/EnterSignerInfo/utils/getSignerDetailsAndSignerFiles.ts +++ b/src/pages/ReimbursementAccount/EnterSignerInfo/utils/getSignerDetailsAndSignerFiles.ts @@ -21,28 +21,28 @@ function getSignerDetailsAndSignerFilesForSignerInfo(enterSignerInfoFormDraft: O const signerDetails: Record = {}; const signerFiles: Record = {}; - signerDetailsFields.forEach((fieldName: keyof EnterSignerInfoForm) => { + for (const fieldName of signerDetailsFields as Array) { if (fieldName === INPUT_IDS.SIGNER_EMAIL) { signerDetails[fieldName] = signerEmail; - return; + continue; } if (!enterSignerInfoFormDraft?.[fieldName]) { - return; + continue; } if (fieldName === INPUT_IDS.SIGNER_STREET || fieldName === INPUT_IDS.SIGNER_CITY || fieldName === INPUT_IDS.SIGNER_STATE || fieldName === INPUT_IDS.SIGNER_ZIP_CODE) { signerDetails[INPUT_IDS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS] = signerDetails[INPUT_IDS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS] ? `${SafeString(signerDetails[INPUT_IDS.SIGNER_COMPLETE_RESIDENTIAL_ADDRESS])}, ${String(enterSignerInfoFormDraft?.[fieldName])}` : enterSignerInfoFormDraft?.[fieldName]; - return; + continue; } const value = enterSignerInfoFormDraft?.[fieldName]; if (typeof value === 'string' || typeof value === 'boolean' || Array.isArray(value)) { signerDetails[fieldName] = value; } - }); + } for (const fieldName of signerFilesFields) { if (!enterSignerInfoFormDraft?.[fieldName]) { From 740e0e39a1aab2bc9971eb18f6909088753d3004 Mon Sep 17 00:00:00 2001 From: gelocraft Date: Thu, 4 Dec 2025 21:34:10 +0000 Subject: [PATCH 6/6] refactor: accept roryabraham code suggestions --- src/libs/actions/Policy/Policy.ts | 15 ++++----- src/libs/actions/Search.ts | 53 +++++++++++++++++++------------ 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index abc46ccaac87..d54f16ac853e 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -2417,10 +2417,12 @@ function buildPolicyData(options: BuildPolicyDataOptions = {}) { } if (getAdminPolicies().length === 0 && lastUsedPaymentMethod) { - const iouReports = Object.values(deprecatedAllReports ?? {}).filter((iouReport) => iouReport?.type === CONST.REPORT.TYPE.IOU); - for (const iouReport of iouReports) { - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (lastUsedPaymentMethod?.iou?.name || !iouReport?.policyID) { + for (const report of Object.values(deprecatedAllReports ?? {})) { + if (report?.type !== CONST.REPORT.TYPE.IOU) { + continue; + } + + if (lastUsedPaymentMethod?.iou?.name || !report?.policyID) { continue; } @@ -2428,13 +2430,10 @@ function buildPolicyData(options: BuildPolicyDataOptions = {}) { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_LAST_PAYMENT_METHOD, value: { - [iouReport?.policyID]: { + [report?.policyID]: { iou: { name: policyID, }, - lastUsed: { - name: policyID, - }, }, }, }); diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index eee9b20d4b59..c23a9ad88126 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -791,21 +791,35 @@ function rejectMoneyRequestsOnSearch(hash: number, selectedTransactions: Selecte type Params = Record; function exportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDList}: ExportSearchItemsToCSVParams, onDownloadFailed: () => void) { - const reportIDListParams: string[] = []; + const reportIDSet = new Set(); + const transactionIDSet = new Set(transactionIDList); for (const reportID of reportIDList) { - const allReportTransactions = getReportTransactions(reportID).filter((transaction) => transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); - const allTransactionIDs = allReportTransactions.map((transaction) => transaction.transactionID); - if (allTransactionIDs.every((transactionID) => transactionIDList.includes(transactionID))) { - if (reportIDListParams.includes(reportID)) { + const allReportTransactions = getReportTransactions(reportID); + + // We'll include the report if all of its transactions are included in the transactionIDList + let areAllTransactionsIncludedInList = true; + for (const transaction of allReportTransactions) { + // Ignore transactions that are pending deletion + if (transaction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { continue; } - reportIDListParams.push(reportID); + + // If any transaction is not included in the transactionIDList, we'll exclude the report + if (!transactionIDSet.has(transaction.transactionID)) { + areAllTransactionsIncludedInList = false; + break; + } + } + + if (areAllTransactionsIncludedInList) { + reportIDSet.add(reportID); } } + const finalParameters = enhanceParameters(WRITE_COMMANDS.EXPORT_SEARCH_ITEMS_TO_CSV, { query, jsonQuery, - reportIDList: reportIDListParams, + reportIDList: Array.from(reportIDSet), transactionIDList, }) as Params; @@ -917,21 +931,20 @@ function clearAllFilters() { function clearAdvancedFilters() { const values: Partial> = {}; - const filterKeys = Object.values(FILTER_KEYS).filter((key) => key !== FILTER_KEYS.GROUP_BY); - for (const key of filterKeys) { - if (key === FILTER_KEYS.TYPE) { - values[key] = CONST.SEARCH.DATA_TYPES.EXPENSE; - continue; - } - - if (key === FILTER_KEYS.STATUS) { - values[key] = CONST.SEARCH.STATUS.EXPENSE.ALL; - continue; + for (const key of Object.values(FILTER_KEYS)) { + switch (key) { + case FILTER_KEYS.GROUP_BY: + continue; + case FILTER_KEYS.TYPE: + values[key] = CONST.SEARCH.DATA_TYPES.EXPENSE; + continue; + case FILTER_KEYS.STATUS: + values[key] = CONST.SEARCH.STATUS.EXPENSE.ALL; + continue; + default: + values[key] = null; } - - values[key] = null; } - Onyx.merge(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, values); }