Skip to content

Commit

Permalink
Merge pull request #41945 from Expensify/youssef_uneven_split_room
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl authored May 9, 2024
2 parents 548a23c + c2e3a90 commit db469d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
17 changes: 8 additions & 9 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -209,7 +206,6 @@ function MoneyRequestConfirmationList({
policyTags,
iouCurrencyCode,
iouMerchant,
hasMultipleParticipants,
selectedParticipants: selectedParticipantsProp,
payeePersonalDetails: payeePersonalDetailsProp,
session,
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) {
Expand All @@ -512,7 +511,7 @@ function MoneyRequestConfirmationList({

const optionSelectorSections = useMemo(() => {
const sections = [];
if (hasMultipleParticipants) {
if (isTypeSplit) {
sections.push(
...[
{
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/pages/iou/SplitBillDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr
)}
{!!participants.length && (
<MoneyRequestConfirmationList
hasMultipleParticipants
payeePersonalDetails={payeePersonalDetails}
selectedParticipants={participantsExcludingPayee}
iouAmount={splitAmount ?? 0}
Expand Down
3 changes: 1 addition & 2 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -558,7 +558,6 @@ function IOURequestStepConfirmation({
/>
<MoneyRequestConfirmationList
transaction={transaction}
hasMultipleParticipants={iouType === CONST.IOU.TYPE.SPLIT}
selectedParticipants={participants}
iouAmount={Math.abs(transaction?.amount ?? 0)}
iouComment={transaction?.comment.comment ?? ''}
Expand Down

0 comments on commit db469d6

Please sign in to comment.