From f8116b35fe294906ae82a184e4608d0a52249cb6 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 19 Apr 2024 23:18:13 +0100 Subject: [PATCH] Allow excluding group chat users from splits by setting amount to 0 --- src/libs/actions/IOU.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 9bcc5143fa00..e4704a4643e0 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3298,6 +3298,12 @@ function createSplitsAndOnyxData( const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(participant); const splitAmount = isPolicyExpenseChat ? IOUUtils.calculateAmount(participants.length, amount, currency, false) : splitShares[participant.accountID ?? 0].amount; + // To exclude someone from a split, the amount can be 0. The scenario for this is when creating a split from a group chat, we have remove the option to deselect users to exclude them. + // We can input '0' next to someone we want to exclude. + if (splitAmount === 0) { + return; + } + // In case the participant is a workspace, email & accountID should remain undefined and won't be used in the rest of this code // participant.login is undefined when the request is initiated from a group DM with an unknown user, so we need to add a default const email = isOwnPolicyExpenseChat || isPolicyExpenseChat ? '' : PhoneNumber.addSMSDomainIfPhoneNumber(participant.login ?? '').toLowerCase();