Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getting unselected participants #32823

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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