From c235091388e74be7b12d7355c1171ff099bf978d Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Mon, 29 Aug 2022 17:07:15 +0200 Subject: [PATCH] Remove null with filter and clean policy members --- src/components/AvatarWithIndicator.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/AvatarWithIndicator.js b/src/components/AvatarWithIndicator.js index 0d936c238eac..df578b01a3a8 100644 --- a/src/components/AvatarWithIndicator.js +++ b/src/components/AvatarWithIndicator.js @@ -61,7 +61,8 @@ const AvatarWithIndicator = (props) => { // If a policy was just deleted from Onyx, then Onyx will pass a null value to the props, and // those should be cleaned out before doing any error checking - const cleanPolicies = _.compact(props.policies); + const cleanPolicies = _.filter(props.policies, policy => policy); + const cleanPolicyMembers = _.filter(props.policiesMemberList, member => member); // All of the error-checking methods are put into an array. This is so that using _.some() will return // early as soon as the first error is returned. This makes the error checking very efficient since @@ -71,7 +72,7 @@ const AvatarWithIndicator = (props) => { () => PaymentMethods.hasPaymentMethodError(props.bankAccountList, props.cardList), () => _.some(cleanPolicies, PolicyUtils.hasPolicyError), () => _.some(cleanPolicies, PolicyUtils.hasCustomUnitsError), - () => _.some(props.policiesMemberList, PolicyUtils.hasPolicyMemberError), + () => _.some(cleanPolicyMembers, PolicyUtils.hasPolicyMemberError), ]; const shouldShowIndicator = _.some(errorCheckingMethods, errorCheckingMethod => errorCheckingMethod());