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

[CP Staging] Fix even shares shown when splitting from workspace rooms #41945

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
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
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}
Copy link
Contributor Author

@youssef-lr youssef-lr May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary param. We already have this condition inside the component which is isTypeSplit

selectedParticipants={participants}
iouAmount={Math.abs(transaction?.amount ?? 0)}
iouComment={transaction?.comment.comment ?? ''}
Expand Down
Loading