From 7a3c402a140ab636b3bb48572048dadcbfdd92f0 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Fri, 31 May 2024 23:11:32 +0530 Subject: [PATCH 1/5] make merchant required for invoices --- src/components/MoneyRequestConfirmationList.tsx | 2 +- src/pages/iou/request/step/IOURequestStepMerchant.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index b18a98b13304..bd9053a2bb6b 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -340,7 +340,7 @@ function MoneyRequestConfirmationList({ }, [isEditingSplitBill, hasSmartScanFailed, transaction, didConfirmSplit]); const isMerchantEmpty = useMemo(() => !iouMerchant || TransactionUtils.isMerchantMissing(transaction), [transaction, iouMerchant]); - const isMerchantRequired = isPolicyExpenseChat && (!isScanRequest || isEditingSplitBill) && shouldShowMerchant; + const isMerchantRequired = ((isPolicyExpenseChat && (!isScanRequest || isEditingSplitBill)) || isTypeInvoice) && shouldShowMerchant; const shouldDisplayMerchantError = isMerchantRequired && (shouldDisplayFieldError || formError === 'iou.error.invalidMerchant') && isMerchantEmpty; const isCategoryRequired = !!policy?.requiresCategory; diff --git a/src/pages/iou/request/step/IOURequestStepMerchant.tsx b/src/pages/iou/request/step/IOURequestStepMerchant.tsx index fc7d39b49089..6dd7621edc52 100644 --- a/src/pages/iou/request/step/IOURequestStepMerchant.tsx +++ b/src/pages/iou/request/step/IOURequestStepMerchant.tsx @@ -60,10 +60,11 @@ function IOURequestStepMerchant({ // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value const isEditingSplitBill = iouType === CONST.IOU.TYPE.SPLIT && isEditing; + const isTypeInvoice = iouType === CONST.IOU.TYPE.INVOICE; const merchant = ReportUtils.getTransactionDetails(isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction)?.merchant; const isEmptyMerchant = merchant === '' || merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; - const isMerchantRequired = ReportUtils.isReportInGroupPolicy(report) || transaction?.participants?.some((participant) => Boolean(participant.isPolicyExpenseChat)); + const isMerchantRequired = ReportUtils.isReportInGroupPolicy(report) || transaction?.participants?.some((participant) => Boolean(participant.isPolicyExpenseChat)) || isTypeInvoice; const navigateBack = () => { Navigation.goBack(backTo); }; From cbeccdb465c79c284dc12e4d98a52792f9b737f7 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Fri, 31 May 2024 23:43:26 +0530 Subject: [PATCH 2/5] Fix lint --- src/components/MoneyRequestConfirmationList.tsx | 2 +- src/pages/iou/request/step/IOURequestStepMerchant.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index bd9053a2bb6b..4152a0bfec50 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -340,7 +340,7 @@ function MoneyRequestConfirmationList({ }, [isEditingSplitBill, hasSmartScanFailed, transaction, didConfirmSplit]); const isMerchantEmpty = useMemo(() => !iouMerchant || TransactionUtils.isMerchantMissing(transaction), [transaction, iouMerchant]); - const isMerchantRequired = ((isPolicyExpenseChat && (!isScanRequest || isEditingSplitBill)) || isTypeInvoice) && shouldShowMerchant; + const isMerchantRequired = ((isPolicyExpenseChat && (!isScanRequest || isEditingSplitBill)) ?? isTypeInvoice) && shouldShowMerchant; const shouldDisplayMerchantError = isMerchantRequired && (shouldDisplayFieldError || formError === 'iou.error.invalidMerchant') && isMerchantEmpty; const isCategoryRequired = !!policy?.requiresCategory; diff --git a/src/pages/iou/request/step/IOURequestStepMerchant.tsx b/src/pages/iou/request/step/IOURequestStepMerchant.tsx index 6dd7621edc52..b79c955d1c22 100644 --- a/src/pages/iou/request/step/IOURequestStepMerchant.tsx +++ b/src/pages/iou/request/step/IOURequestStepMerchant.tsx @@ -64,7 +64,7 @@ function IOURequestStepMerchant({ const merchant = ReportUtils.getTransactionDetails(isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction)?.merchant; const isEmptyMerchant = merchant === '' || merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; - const isMerchantRequired = ReportUtils.isReportInGroupPolicy(report) || transaction?.participants?.some((participant) => Boolean(participant.isPolicyExpenseChat)) || isTypeInvoice; + const isMerchantRequired = ReportUtils.isReportInGroupPolicy(report) ?? transaction?.participants?.some((participant) => Boolean(participant.isPolicyExpenseChat)) ?? isTypeInvoice; const navigateBack = () => { Navigation.goBack(backTo); }; From e41ac309871ad03864c975f4ae78a5725bd9bc85 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Fri, 31 May 2024 23:46:29 +0530 Subject: [PATCH 3/5] Fix lint --- src/components/MoneyRequestConfirmationList.tsx | 2 +- src/pages/iou/request/step/IOURequestStepMerchant.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 4152a0bfec50..bd9053a2bb6b 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -340,7 +340,7 @@ function MoneyRequestConfirmationList({ }, [isEditingSplitBill, hasSmartScanFailed, transaction, didConfirmSplit]); const isMerchantEmpty = useMemo(() => !iouMerchant || TransactionUtils.isMerchantMissing(transaction), [transaction, iouMerchant]); - const isMerchantRequired = ((isPolicyExpenseChat && (!isScanRequest || isEditingSplitBill)) ?? isTypeInvoice) && shouldShowMerchant; + const isMerchantRequired = ((isPolicyExpenseChat && (!isScanRequest || isEditingSplitBill)) || isTypeInvoice) && shouldShowMerchant; const shouldDisplayMerchantError = isMerchantRequired && (shouldDisplayFieldError || formError === 'iou.error.invalidMerchant') && isMerchantEmpty; const isCategoryRequired = !!policy?.requiresCategory; diff --git a/src/pages/iou/request/step/IOURequestStepMerchant.tsx b/src/pages/iou/request/step/IOURequestStepMerchant.tsx index b79c955d1c22..6dd7621edc52 100644 --- a/src/pages/iou/request/step/IOURequestStepMerchant.tsx +++ b/src/pages/iou/request/step/IOURequestStepMerchant.tsx @@ -64,7 +64,7 @@ function IOURequestStepMerchant({ const merchant = ReportUtils.getTransactionDetails(isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction)?.merchant; const isEmptyMerchant = merchant === '' || merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; - const isMerchantRequired = ReportUtils.isReportInGroupPolicy(report) ?? transaction?.participants?.some((participant) => Boolean(participant.isPolicyExpenseChat)) ?? isTypeInvoice; + const isMerchantRequired = ReportUtils.isReportInGroupPolicy(report) || transaction?.participants?.some((participant) => Boolean(participant.isPolicyExpenseChat)) || isTypeInvoice; const navigateBack = () => { Navigation.goBack(backTo); }; From 94899499c6f275822f539a41d137eaef366c657d Mon Sep 17 00:00:00 2001 From: Gandalf Date: Sun, 2 Jun 2024 15:40:06 +0530 Subject: [PATCH 4/5] Fix lint --- src/components/MoneyRequestConfirmationList.tsx | 3 ++- src/pages/iou/request/step/IOURequestStepMerchant.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index bd9053a2bb6b..f0189f33c505 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -15,6 +15,7 @@ import usePrevious from '@hooks/usePrevious'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import ControlSelection from '@libs/ControlSelection'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import type {MileageRate} from '@libs/DistanceRequestUtils'; @@ -340,7 +341,7 @@ function MoneyRequestConfirmationList({ }, [isEditingSplitBill, hasSmartScanFailed, transaction, didConfirmSplit]); const isMerchantEmpty = useMemo(() => !iouMerchant || TransactionUtils.isMerchantMissing(transaction), [transaction, iouMerchant]); - const isMerchantRequired = ((isPolicyExpenseChat && (!isScanRequest || isEditingSplitBill)) || isTypeInvoice) && shouldShowMerchant; + const isMerchantRequired = (isPolicyExpenseChat || isTypeInvoice) && (!isScanRequest || isEditingSplitBill) && shouldShowMerchant; const shouldDisplayMerchantError = isMerchantRequired && (shouldDisplayFieldError || formError === 'iou.error.invalidMerchant') && isMerchantEmpty; const isCategoryRequired = !!policy?.requiresCategory; diff --git a/src/pages/iou/request/step/IOURequestStepMerchant.tsx b/src/pages/iou/request/step/IOURequestStepMerchant.tsx index 6dd7621edc52..99606eb50e5c 100644 --- a/src/pages/iou/request/step/IOURequestStepMerchant.tsx +++ b/src/pages/iou/request/step/IOURequestStepMerchant.tsx @@ -64,7 +64,7 @@ function IOURequestStepMerchant({ const merchant = ReportUtils.getTransactionDetails(isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction)?.merchant; const isEmptyMerchant = merchant === '' || merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; - const isMerchantRequired = ReportUtils.isReportInGroupPolicy(report) || transaction?.participants?.some((participant) => Boolean(participant.isPolicyExpenseChat)) || isTypeInvoice; + const isMerchantRequired = ReportUtils.isReportInGroupPolicy(report) || isTypeInvoice || transaction?.participants?.some((participant) => Boolean(participant.isPolicyExpenseChat)); const navigateBack = () => { Navigation.goBack(backTo); }; From ec144135fa3fa7f10d23c6aa7e1f8e5b407d4319 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Sun, 2 Jun 2024 15:55:54 +0530 Subject: [PATCH 5/5] fix lint --- src/components/MoneyRequestConfirmationList.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index f0189f33c505..3008715277ec 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -15,7 +15,6 @@ import usePrevious from '@hooks/usePrevious'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import ControlSelection from '@libs/ControlSelection'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import type {MileageRate} from '@libs/DistanceRequestUtils';