From e4d13158f3527426a8f84c562439bc1cdd10811e Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 5 Mar 2024 21:12:45 +0800 Subject: [PATCH 1/2] show merchant field required error if it's a policy expense chat --- src/libs/TransactionUtils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index 67e31c610369..c01b248cb023 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -167,7 +167,9 @@ function isCreatedMissing(transaction: Transaction) { function areRequiredFieldsEmpty(transaction: Transaction): boolean { const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`] ?? null; const isFromExpenseReport = parentReport?.type === CONST.REPORT.TYPE.EXPENSE; - return (isFromExpenseReport && isMerchantMissing(transaction)) || isAmountMissing(transaction) || isCreatedMissing(transaction); + const isSplitPolicyExpenseChat = transaction.comment?.splits?.some((participant) => allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${participant.chatReportID}`]?.isOwnPolicyExpenseChat); + const isMerchantRequired = isFromExpenseReport || isSplitPolicyExpenseChat; + return (isMerchantRequired && isMerchantMissing(transaction)) || isAmountMissing(transaction) || isCreatedMissing(transaction); } /** From 9c7e765aa4f225315716538957d2ab709b356d0f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 5 Mar 2024 21:29:10 +0800 Subject: [PATCH 2/2] fix lint --- src/libs/TransactionUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index c01b248cb023..8a98fe0f2cdc 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -167,7 +167,7 @@ function isCreatedMissing(transaction: Transaction) { function areRequiredFieldsEmpty(transaction: Transaction): boolean { const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`] ?? null; const isFromExpenseReport = parentReport?.type === CONST.REPORT.TYPE.EXPENSE; - const isSplitPolicyExpenseChat = transaction.comment?.splits?.some((participant) => allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${participant.chatReportID}`]?.isOwnPolicyExpenseChat); + const isSplitPolicyExpenseChat = !!transaction.comment?.splits?.some((participant) => allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${participant.chatReportID}`]?.isOwnPolicyExpenseChat); const isMerchantRequired = isFromExpenseReport || isSplitPolicyExpenseChat; return (isMerchantRequired && isMerchantMissing(transaction)) || isAmountMissing(transaction) || isCreatedMissing(transaction); }