From 1db08ef4bf20b522af2ba1e2843421458d6d271b Mon Sep 17 00:00:00 2001 From: gelocraft Date: Fri, 12 Dec 2025 22:14:53 +0000 Subject: [PATCH 1/2] fix(eslint): unicorn/no-array-for-each --- .../OnyxDerived/configs/reportAttributes.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts index 51927bebd438a..e53929705aa1d 100644 --- a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts +++ b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts @@ -143,12 +143,12 @@ export default createOnyxDerivedValueConfig({ // When an IOU report changes, we need to re-evaluate its parent chat report as well. const parentChatReportIDsToUpdate = new Set(); - dataToIterate.forEach((reportKey) => { + for (const reportKey of dataToIterate) { const report = reports[reportKey]; if (report?.chatReportID && report.reportID !== report.chatReportID) { parentChatReportIDsToUpdate.add(`${ONYXKEYS.COLLECTION.REPORT}${report.chatReportID}`); } - }); + } if (parentChatReportIDsToUpdate.size > 0) { dataToIterate.push(...Array.from(parentChatReportIDsToUpdate)); } @@ -228,9 +228,9 @@ export default createOnyxDerivedValueConfig({ // Propagate errors from IOU reports to their parent chat reports. const chatReportIDsWithErrors = new Set(); - Object.values(reports).forEach((report) => { + for (const report of Object.values(reports)) { if (!report?.reportID) { - return; + continue; } // If this is an IOU report and its calculated attributes have an error, @@ -239,14 +239,14 @@ export default createOnyxDerivedValueConfig({ if (report.chatReportID && report.reportID !== report.chatReportID && attributes?.brickRoadStatus === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR) { chatReportIDsWithErrors.add(report.chatReportID); } - }); + } // Apply the error status to the parent chat reports. - chatReportIDsWithErrors.forEach((chatReportID) => { + for (const chatReportID of chatReportIDsWithErrors) { if (reportAttributes[chatReportID]) { reportAttributes[chatReportID].brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; } - }); + } // mark the report attributes as fully computed after first iteration to avoid unnecessary recomputation on all objects if (!Object.keys(reportUpdates).length && Object.keys(reports ?? {}).length > 0 && !isFullyComputed) { From 22a459fcffcea5280326660b395163703c6d28b8 Mon Sep 17 00:00:00 2001 From: gelocraft Date: Fri, 12 Dec 2025 23:37:54 +0000 Subject: [PATCH 2/2] refactor: accept dangrous code suggestion --- src/libs/actions/OnyxDerived/configs/reportAttributes.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts index e53929705aa1d..85c461d949db4 100644 --- a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts +++ b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts @@ -243,9 +243,10 @@ export default createOnyxDerivedValueConfig({ // Apply the error status to the parent chat reports. for (const chatReportID of chatReportIDsWithErrors) { - if (reportAttributes[chatReportID]) { - reportAttributes[chatReportID].brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; + if (!reportAttributes[chatReportID]) { + continue; } + reportAttributes[chatReportID].brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; } // mark the report attributes as fully computed after first iteration to avoid unnecessary recomputation on all objects