Skip to content

Commit

Permalink
Merge pull request #32823 from s-alves10/fix/issue-32808
Browse files Browse the repository at this point in the history
fix: getting unselected participants
  • Loading branch information
tgolen authored Dec 11, 2023
2 parents 103651c + 7e362f2 commit e5df7f6
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/components/MoneyTemporaryForRefactorRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
receiptPath,
reportActionID,
reportID,
selectedParticipants,
selectedParticipants: pickedParticipants,
session: {accountID},
shouldShowSmartScanFields,
transaction,
Expand Down Expand Up @@ -358,7 +358,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
];
}, [isTypeSplit, isTypeRequest, iouType, iouAmount, receiptPath, formattedAmount, isDistanceRequestWithoutRoute, translate]);

const selectedParticipantsFiltered = useMemo(() => _.filter(selectedParticipants, (participant) => participant.selected), [selectedParticipants]);
const selectedParticipants = useMemo(() => _.filter(pickedParticipants, (participant) => participant.selected), [pickedParticipants]);
const personalDetailsOfPayee = useMemo(() => payeePersonalDetails || currentUserPersonalDetails, [payeePersonalDetails, currentUserPersonalDetails]);
const userCanModifyParticipants = useRef(!isReadOnly && canModifyParticipants && hasMultipleParticipants);
useEffect(() => {
Expand All @@ -368,9 +368,9 @@ function MoneyTemporaryForRefactorRequestConfirmationList({

const optionSelectorSections = useMemo(() => {
const sections = [];
const unselectedParticipants = _.filter(selectedParticipantsFiltered, (participant) => !participant.selected);
const unselectedParticipants = _.filter(pickedParticipants, (participant) => !participant.selected);
if (hasMultipleParticipants) {
const formattedSelectedParticipants = getParticipantsWithAmount(selectedParticipantsFiltered);
const formattedSelectedParticipants = getParticipantsWithAmount(selectedParticipants);
let formattedParticipantsList = _.union(formattedSelectedParticipants, unselectedParticipants);

if (!userCanModifyParticipants.current) {
Expand All @@ -380,7 +380,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
}));
}

const myIOUAmount = IOUUtils.calculateAmount(selectedParticipantsFiltered.length, iouAmount, iouCurrencyCode, true);
const myIOUAmount = IOUUtils.calculateAmount(selectedParticipants.length, iouAmount, iouCurrencyCode, true);
const formattedPayeeOption = OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(
personalDetailsOfPayee,
iouAmount > 0 ? CurrencyUtils.convertToDisplayString(myIOUAmount, iouCurrencyCode) : '',
Expand All @@ -402,7 +402,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
},
);
} else {
const formattedSelectedParticipants = _.map(selectedParticipantsFiltered, (participant) => ({
const formattedSelectedParticipants = _.map(selectedParticipants, (participant) => ({
...participant,
isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID),
}));
Expand All @@ -415,7 +415,8 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
}
return sections;
}, [
selectedParticipantsFiltered,
selectedParticipants,
pickedParticipants,
hasMultipleParticipants,
iouAmount,
iouCurrencyCode,
Expand All @@ -430,8 +431,8 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
if (!hasMultipleParticipants) {
return [];
}
return [...selectedParticipantsFiltered, OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(personalDetailsOfPayee)];
}, [selectedParticipantsFiltered, hasMultipleParticipants, personalDetailsOfPayee]);
return [...selectedParticipants, OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(personalDetailsOfPayee)];
}, [selectedParticipants, hasMultipleParticipants, personalDetailsOfPayee]);

useEffect(() => {
if (!isDistanceRequest) {
Expand Down Expand Up @@ -474,7 +475,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
*/
const confirm = useCallback(
(paymentMethod) => {
if (_.isEmpty(selectedParticipantsFiltered)) {
if (_.isEmpty(selectedParticipants)) {
return;
}

Expand Down Expand Up @@ -502,10 +503,10 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
}

setDidConfirm(true);
onConfirm(selectedParticipantsFiltered);
onConfirm(selectedParticipants);
}
},
[selectedParticipantsFiltered, onSendMoney, onConfirm, isEditingSplitBill, iouType, isDistanceRequest, isDistanceRequestWithoutRoute, iouCurrencyCode, iouAmount, transaction],
[selectedParticipants, onSendMoney, onConfirm, isEditingSplitBill, iouType, isDistanceRequest, isDistanceRequestWithoutRoute, iouCurrencyCode, iouAmount, transaction],
);

const footerContent = useMemo(() => {
Expand All @@ -514,7 +515,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
}

const shouldShowSettlementButton = iouType === CONST.IOU.TYPE.SEND;
const shouldDisableButton = selectedParticipantsFiltered.length === 0;
const shouldDisableButton = selectedParticipants.length === 0;

const button = shouldShowSettlementButton ? (
<SettlementButton
Expand Down Expand Up @@ -558,7 +559,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
{button}
</>
);
}, [confirm, bankAccountRoute, iouCurrencyCode, iouType, isReadOnly, policyID, selectedParticipantsFiltered, splitOrRequestOptions, translate, formError, styles.ph1, styles.mb2]);
}, [confirm, bankAccountRoute, iouCurrencyCode, iouType, isReadOnly, policyID, selectedParticipants, splitOrRequestOptions, translate, formError, styles.ph1, styles.mb2]);

const {image: receiptImage, thumbnail: receiptThumbnail} = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : {};
return (
Expand Down

0 comments on commit e5df7f6

Please sign in to comment.