diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 5a4b39e7c8946..4c0dd8daa8bf3 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -215,6 +215,9 @@ type MoneyRequestConfirmationListProps = { /** Show remove expense confirmation modal */ showRemoveExpenseConfirmModal?: () => void; + + /** When true, hide the "To:" section (e.g. when adding an expense directly to the current report) */ + shouldHideToSection?: boolean; }; type MoneyRequestConfirmationListItem = (Participant & {keyForList: string}) | OptionData; @@ -266,6 +269,7 @@ function MoneyRequestConfirmationList({ isTimeRequest = false, iouTimeCount, iouTimeRate, + shouldHideToSection = false, }: MoneyRequestConfirmationListProps) { const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, {canBeMissing: true}); const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, {canBeMissing: true}); @@ -833,19 +837,22 @@ function MoneyRequestConfirmationList({ }, ); } else { - const formattedSelectedParticipants = selectedParticipants.map((participant) => ({ - ...participant, - isSelected: false, - keyForList: `${participant.keyForList ?? participant.accountID ?? participant.reportID}`, - isInteractive: isFromGlobalCreateAndCanEditParticipant && !isTestReceipt && (!isRestrictedToPreferredPolicy || isTypeInvoice), - shouldShowRightCaret: isFromGlobalCreateAndCanEditParticipant && !isTestReceipt && (!isRestrictedToPreferredPolicy || isTypeInvoice), - })); - - options.push({ - title: translate('common.to'), - data: formattedSelectedParticipants, - sectionIndex: 0, - }); + // When adding an expense from within a report, hide the "To:" section since the destination is already the current report + if (!shouldHideToSection) { + const formattedSelectedParticipants = selectedParticipants.map((participant) => ({ + ...participant, + isSelected: false, + keyForList: `${participant.keyForList ?? participant.accountID ?? participant.reportID}`, + isInteractive: isFromGlobalCreateAndCanEditParticipant && !isTestReceipt && (!isRestrictedToPreferredPolicy || isTypeInvoice), + shouldShowRightCaret: isFromGlobalCreateAndCanEditParticipant && !isTestReceipt && (!isRestrictedToPreferredPolicy || isTypeInvoice), + })); + + options.push({ + title: translate('common.to'), + data: formattedSelectedParticipants, + sectionIndex: 0, + }); + } } return options; @@ -860,6 +867,7 @@ function MoneyRequestConfirmationList({ isTestReceipt, isRestrictedToPreferredPolicy, isTypeInvoice, + shouldHideToSection, ]); useEffect(() => { @@ -1358,5 +1366,6 @@ export default memo( prevProps.shouldDisplayReceipt === nextProps.shouldDisplayReceipt && prevProps.isTimeRequest === nextProps.isTimeRequest && prevProps.iouTimeCount === nextProps.iouTimeCount && - prevProps.iouTimeRate === nextProps.iouTimeRate, + prevProps.iouTimeRate === nextProps.iouTimeRate && + prevProps.shouldHideToSection === nextProps.shouldHideToSection, ); diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 0a9cc770411bf..4d3a502d3765c 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -57,6 +57,7 @@ import { generateReportID, getReportOrDraftReport, hasViolations as hasViolationsReportUtils, + isMoneyRequestReport, isProcessingReport, isReportOutstanding, isSelectedManagerMcTest, @@ -173,6 +174,7 @@ function IOURequestStepConfirmation({ const canUseReport = !(isProcessingReport(transactionReport) && !policyReal?.harvesting?.enabled) && isReportOutstanding(transactionReport, policyReal?.id, undefined, false); const shouldUseTransactionReport = !!transactionReport && (canUseReport || !reportWithDraftFallback); + const shouldHideToSection = useMemo(() => isMoneyRequestReport(reportWithDraftFallback), [reportWithDraftFallback]); const isTransactionReportDifferentFromRoute = useMemo( () => !!transaction?.reportID && !!reportWithDraftFallback?.reportID && transaction.reportID !== reportWithDraftFallback.reportID, [reportWithDraftFallback?.reportID, transaction?.reportID], @@ -1488,6 +1490,7 @@ function IOURequestStepConfirmation({ isTimeRequest={isTimeRequest} iouTimeCount={transaction?.comment?.units?.count} iouTimeRate={transaction?.comment?.units?.rate} + shouldHideToSection={shouldHideToSection} />