From bf1375074e2da058f76d33238079442c4cef9475 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Thu, 9 May 2024 20:16:16 +0100 Subject: [PATCH 1/2] Fix isPolicyExpenseChat wrongly being set to true --- src/components/MoneyRequestConfirmationList.tsx | 17 ++++++++--------- .../request/step/IOURequestStepConfirmation.tsx | 3 +-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 2c592c20f4c6..10fb0430dec7 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -102,9 +102,6 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & /** Callback to inform a participant is selected */ onSelectParticipant?: (option: Participant) => void; - /** Should we request a single or multiple participant selection from user */ - hasMultipleParticipants: boolean; - /** IOU amount */ iouAmount: number; @@ -209,7 +206,6 @@ function MoneyRequestConfirmationList({ policyTags, iouCurrencyCode, iouMerchant, - hasMultipleParticipants, selectedParticipants: selectedParticipantsProp, payeePersonalDetails: payeePersonalDetailsProp, session, @@ -466,6 +462,9 @@ function MoneyRequestConfirmationList({ const shouldShowReadOnlySplits = useMemo(() => isPolicyExpenseChat || isReadOnly || isScanRequest, [isPolicyExpenseChat, isReadOnly, isScanRequest]); const splitParticipants = useMemo(() => { + if (!isTypeSplit) { + return; + } const payeeOption = OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(payeePersonalDetails); if (shouldShowReadOnlySplits) { return [payeeOption, ...selectedParticipants].map((participantOption: Participant) => { @@ -501,7 +500,7 @@ function MoneyRequestConfirmationList({ onAmountChange: (value: string) => onSplitShareChange(participantOption.accountID ?? 0, Number(value)), }, })); - }, [transaction, iouCurrencyCode, onSplitShareChange, payeePersonalDetails, selectedParticipants, currencyList, iouAmount, shouldShowReadOnlySplits, StyleUtils]); + }, [isTypeSplit, transaction, iouCurrencyCode, onSplitShareChange, payeePersonalDetails, selectedParticipants, currencyList, iouAmount, shouldShowReadOnlySplits, StyleUtils]); const isSplitModified = useMemo(() => { if (!transaction?.splitShares) { @@ -512,7 +511,7 @@ function MoneyRequestConfirmationList({ const optionSelectorSections = useMemo(() => { const sections = []; - if (hasMultipleParticipants) { + if (isTypeSplit) { sections.push( ...[ { @@ -543,14 +542,14 @@ function MoneyRequestConfirmationList({ }); } return sections; - }, [selectedParticipants, hasMultipleParticipants, translate, splitParticipants, transaction, shouldShowReadOnlySplits, isSplitModified, payeePersonalDetails]); + }, [selectedParticipants, isTypeSplit, translate, splitParticipants, transaction, shouldShowReadOnlySplits, isSplitModified, payeePersonalDetails]); const selectedOptions = useMemo(() => { - if (!hasMultipleParticipants) { + if (!isTypeSplit) { return []; } return [...selectedParticipants, OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(payeePersonalDetails)]; - }, [selectedParticipants, hasMultipleParticipants, payeePersonalDetails]); + }, [selectedParticipants, isTypeSplit, payeePersonalDetails]); useEffect(() => { if (!isDistanceRequest || isMovingTransactionFromTrackExpense) { diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index e458e57ae3bb..33fe560cb7ad 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -146,7 +146,7 @@ function IOURequestStepConfirmation({ }) ?? [], [transaction?.participants, personalDetails, iouType], ); - const isPolicyExpenseChat = useMemo(() => ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)) || ReportUtils.isGroupPolicy(policy?.type ?? ''), [report, policy]); + const isPolicyExpenseChat = useMemo(() => participants?.some((participant) => participant.isPolicyExpenseChat), [participants]); const formHasBeenSubmitted = useRef(false); useEffect(() => { @@ -558,7 +558,6 @@ function IOURequestStepConfirmation({ /> Date: Thu, 9 May 2024 20:22:17 +0100 Subject: [PATCH 2/2] Remove extra param --- src/pages/iou/SplitBillDetailsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/iou/SplitBillDetailsPage.tsx b/src/pages/iou/SplitBillDetailsPage.tsx index 157f14d1dde5..51b432d7e860 100644 --- a/src/pages/iou/SplitBillDetailsPage.tsx +++ b/src/pages/iou/SplitBillDetailsPage.tsx @@ -107,7 +107,6 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr )} {!!participants.length && (