From d74c50c53ef75e84d0679825baa6692d000d14b2 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Wed, 12 Mar 2025 10:21:04 -0400 Subject: [PATCH] CASH-152: refactor/improve recal-helper --- src/helpers/recal-helper.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/helpers/recal-helper.js b/src/helpers/recal-helper.js index d43da5d34..2794bbcf6 100644 --- a/src/helpers/recal-helper.js +++ b/src/helpers/recal-helper.js @@ -35,10 +35,9 @@ export function containsRecalParts(lineItems) { } } -export function getItemsWithoutRecalParts(lineItems) { - const copy = deepClone(lineItems); - - const firstLevelFiltered = copy.filter((li) => !isRecalPart(li)); +export function getItemsWithoutRecalParts(lineItemsArray) { + if (!lineItemsArray || !Array.isArray(lineItemsArray)) return null; + const firstLevelFiltered = deepClone(lineItemsArray).filter((li) => !isRecalPart(li)); const childrenFiltered = firstLevelFiltered.map((li) => { if (li.childParts && li.childParts.length > 0) {