Skip to content

Commit

Permalink
show merchant field required error if it's a policy expense chat
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Mar 5, 2024
1 parent 9411a08 commit e4d1315
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check failure on line 172 in src/libs/TransactionUtils.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator
}

/**
Expand Down

0 comments on commit e4d1315

Please sign in to comment.