From 9403efc20fd4ea92e47f66893288a6f4208e571a Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 27 Nov 2025 16:24:26 +0100 Subject: [PATCH 1/2] fix: show error when category out of policy --- src/components/MoneyRequestConfirmationList.tsx | 5 +++++ src/components/MoneyRequestConfirmationListFooter.tsx | 4 ++++ src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 5 ----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index ac601e5f361e..d948e6644d30 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -891,6 +891,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 53a62103a273..5426b657a2ba 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -371,6 +371,8 @@ function MoneyRequestConfirmationListFooter({ const shouldDisplayMerchantError = isMerchantRequired && (shouldDisplayFieldError || formError === 'iou.error.invalidMerchant') && isMerchantEmpty; const shouldDisplayDistanceRateError = formError === 'iou.error.invalidRate'; const shouldDisplayTagError = formError === 'violations.tagOutOfPolicy'; + const shouldDisplayCategoryError = formError === 'violations.categoryOutOfPolicy'; + const showReceiptEmptyState = shouldShowReceiptEmptyState(iouType, action, policy, isPerDiemRequest); // The per diem custom unit @@ -605,6 +607,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 e9b6e26842c3..7aee95923a81 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); - } } // 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 From 892bd26aaf84efcb0eef5f8356c89e20aed1177d Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Fri, 28 Nov 2025 11:34:15 +0100 Subject: [PATCH 2/2] fix: prettier --- src/components/MoneyRequestConfirmationListFooter.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index 5426b657a2ba..23ed75e22235 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -373,7 +373,6 @@ function MoneyRequestConfirmationListFooter({ const shouldDisplayTagError = formError === 'violations.tagOutOfPolicy'; const shouldDisplayCategoryError = formError === 'violations.categoryOutOfPolicy'; - const showReceiptEmptyState = shouldShowReceiptEmptyState(iouType, action, policy, isPerDiemRequest); // The per diem custom unit const perDiemCustomUnit = getPerDiemCustomUnit(policy);