From 2e5faefe6704a2a8bde2a546dd7710e8b1ba69a7 Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 12 Aug 2024 13:23:08 +0700 Subject: [PATCH 1/2] fix: remove Expensify employee from list participants --- .../MoneyRequestConfirmationList.tsx | 56 ++++++++++--------- src/libs/ReportUtils.ts | 4 +- .../iou/request/step/IOURequestStepAmount.tsx | 6 +- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 8ab996dcbfe9..458e5fbbaca1 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -483,33 +483,35 @@ function MoneyRequestConfirmationList({ const currencySymbol = currencyList?.[iouCurrencyCode ?? '']?.symbol ?? iouCurrencyCode; const formattedTotalAmount = CurrencyUtils.convertToDisplayStringWithoutCurrency(iouAmount, iouCurrencyCode); - return [payeeOption, ...selectedParticipants].map((participantOption: Participant) => ({ - ...participantOption, - tabIndex: -1, - isSelected: false, - isInteractive: !shouldDisableParticipant(participantOption), - rightElement: ( - onSplitShareChange(participantOption.accountID ?? -1, Number(value))} - maxLength={formattedTotalAmount.length} - contentWidth={formattedTotalAmount.length * 8} - /> - ), - })); + return [payeeOption, ...selectedParticipants] + .filter((participantOption) => !PolicyUtils.isExpensifyTeam(participantOption.login)) + .map((participantOption: Participant) => ({ + ...participantOption, + tabIndex: -1, + isSelected: false, + isInteractive: !shouldDisableParticipant(participantOption), + rightElement: ( + onSplitShareChange(participantOption.accountID ?? -1, Number(value))} + maxLength={formattedTotalAmount.length} + contentWidth={formattedTotalAmount.length * 8} + /> + ), + })); }, [ isTypeSplit, payeePersonalDetails, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 62e259b8f05c..968c88019ea2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6196,7 +6196,9 @@ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry currentUserPersonalDetails?.accountID !== accountID); + const otherParticipants = reportParticipants.filter( + (accountID) => currentUserPersonalDetails?.accountID !== accountID && !PolicyUtils.isExpensifyTeam(allPersonalDetails?.[accountID]?.login), + ); const hasSingleParticipantInReport = otherParticipants.length === 1; let options: IOUType[] = []; diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 069f86ce0899..a7457c88280d 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -10,6 +10,7 @@ import * as TransactionEdit from '@libs/actions/TransactionEdit'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; +import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import {getRequestType} from '@libs/TransactionUtils'; @@ -79,6 +80,7 @@ function IOURequestStepAmount({ const isSaveButtonPressed = useRef(false); const iouRequestType = getRequestType(transaction); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); + const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const isEditing = action === CONST.IOU.ACTION.EDIT; const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; @@ -253,7 +255,9 @@ function IOURequestStepAmount({ } IOU.setMoneyRequestParticipantsFromReport(transactionID, report); if (isSplitBill && !report.isOwnPolicyExpenseChat && report.participants) { - const participantAccountIDs = Object.keys(report.participants).map((accountID) => Number(accountID)); + const participantAccountIDs = Object.keys(report.participants) + .map((accountID) => Number(accountID)) + .filter((accountID) => !PolicyUtils.isExpensifyTeam(allPersonalDetails?.[accountID]?.login)); IOU.setSplitShares(transaction, amountInSmallestCurrencyUnits, currency || CONST.CURRENCY.USD, participantAccountIDs); } navigateToConfirmationPage(); From 34cd6582b773ffaf020afd119d28f4819d92bb68 Mon Sep 17 00:00:00 2001 From: daledah Date: Thu, 22 Aug 2024 17:57:50 +0700 Subject: [PATCH 2/2] fix: add allPersonalDetails to moneyRequestOptions deps --- .../ReportActionCompose/AttachmentPickerWithMenuItems.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index 5d7b5b1390c2..9c61e0178a54 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -7,6 +7,7 @@ import type {FileObject} from '@components/AttachmentModal'; import AttachmentPicker from '@components/AttachmentPicker'; import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; +import {usePersonalDetails} from '@components/OnyxProvider'; import type {PopoverMenuItem} from '@components/PopoverMenu'; import PopoverMenu from '@components/PopoverMenu'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; @@ -122,6 +123,7 @@ function AttachmentPickerWithMenuItems({ const {translate} = useLocalize(); const {windowHeight, windowWidth} = useWindowDimensions(); const {shouldUseNarrowLayout} = useResponsiveLayout(); + const allPersonalDetails = usePersonalDetails(); /** * Returns the list of IOU Options @@ -167,7 +169,8 @@ function AttachmentPickerWithMenuItems({ return ReportUtils.temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? []).map((option) => ({ ...options[option], })); - }, [translate, report, policy, reportParticipantIDs]); + // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps + }, [translate, report, policy, reportParticipantIDs, allPersonalDetails]); /** * Determines if we can show the task option