diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index fe616374347e..9d3734cc611d 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -908,6 +908,11 @@ function MoneyRequestConfirmationList({ return; } + if (iouCategory && policyCategories && (!policyCategories[iouCategory] || !policyCategories[iouCategory]?.enabled)) { + setFormError('violations.categoryOutOfPolicy'); + return; + } + const transactionTag = getTag(transaction); if (transactionTag.length > CONST.API_TRANSACTION_TAG_MAX_LENGTH) { setFormError('iou.error.invalidTagLength'); diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index eec37a60dc1d..bde1179a2379 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -387,6 +387,7 @@ function MoneyRequestConfirmationListFooter({ const shouldDisplayDistanceRateError = formError === 'iou.error.invalidRate'; const shouldDisplayTagError = formError === 'violations.tagOutOfPolicy'; const shouldDisplayTaxRateError = formError === 'violations.taxOutOfPolicy'; + const shouldDisplayCategoryError = formError === 'violations.categoryOutOfPolicy'; const showReceiptEmptyState = shouldShowReceiptEmptyState(iouType, action, policy, isPerDiemRequest); // The per diem custom unit @@ -621,6 +622,8 @@ function MoneyRequestConfirmationListFooter({ disabled={didConfirm} interactive={!isReadOnly} rightLabel={isCategoryRequired ? translate('common.required') : ''} + brickRoadIndicator={shouldDisplayCategoryError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + errorText={shouldDisplayCategoryError ? translate(formError) : ''} /> ), shouldShow: shouldShowCategories, diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index aa835f1348ce..b9c5bd04097f 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -381,11 +381,6 @@ function IOURequestStepConfirmation({ } continue; } - - // Clear category field when the category doesn't exist for selected policy, or it's disabled - if (!policyCategories?.[item.category] || !policyCategories[item.category]?.enabled) { - setMoneyRequestCategory(item.transactionID, '', policy?.id, isMovingTransactionFromTrackExpense); - } } // We don't want to clear out category every time the transactions change // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps