From 8ab7a2516ec199b7ea0fa3066598ced6e9d52c18 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Sun, 5 May 2024 12:46:55 +0530 Subject: [PATCH 1/4] auto fill categories and tags when only one is present --- src/components/MoneyRequestConfirmationList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index b2dac85f70eb..a92ab4b9fcc1 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -340,7 +340,7 @@ function MoneyRequestConfirmationList({ const shouldDisplayMerchantError = isMerchantRequired && (shouldDisplayFieldError || formError === 'iou.error.invalidMerchant') && isMerchantEmpty; - const isCategoryRequired = canUseViolations && !!policy?.requiresCategory; + const isCategoryRequired = !!policy?.requiresCategory; useEffect(() => { if (shouldDisplayFieldError && hasSmartScanFailed) { @@ -545,7 +545,7 @@ function MoneyRequestConfirmationList({ let updatedTagsString = TransactionUtils.getTag(transaction); policyTagLists.forEach((tagList, index) => { const enabledTags = Object.values(tagList.tags).filter((tag) => tag.enabled); - const isTagListRequired = tagList.required === undefined ? false : tagList.required && canUseViolations; + const isTagListRequired = tagList.required === undefined ? false : tagList.required; if (!isTagListRequired || enabledTags.length !== 1 || TransactionUtils.getTag(transaction, index)) { return; } From 635839aac6ad21b633dae3f983ee075c618c9f35 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Sun, 5 May 2024 13:11:48 +0530 Subject: [PATCH 2/4] fix lint --- src/components/MoneyRequestConfirmationList.tsx | 2 +- src/components/test.md | 0 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 src/components/test.md diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index a92ab4b9fcc1..7ad849282e88 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -545,7 +545,7 @@ function MoneyRequestConfirmationList({ let updatedTagsString = TransactionUtils.getTag(transaction); policyTagLists.forEach((tagList, index) => { const enabledTags = Object.values(tagList.tags).filter((tag) => tag.enabled); - const isTagListRequired = tagList.required === undefined ? false : tagList.required; + const isTagListRequired = tagList.required ?? false; if (!isTagListRequired || enabledTags.length !== 1 || TransactionUtils.getTag(transaction, index)) { return; } diff --git a/src/components/test.md b/src/components/test.md new file mode 100644 index 000000000000..e69de29bb2d1 From b507d6030bb2a52bc02b47971bf52c4e72445b74 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Sun, 5 May 2024 13:12:58 +0530 Subject: [PATCH 3/4] fix lint --- src/components/test.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/components/test.md diff --git a/src/components/test.md b/src/components/test.md deleted file mode 100644 index e69de29bb2d1..000000000000 From c289d78d1a7900f86b15ba46a0507fa8df337fcd Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Tue, 7 May 2024 18:57:59 +0530 Subject: [PATCH 4/4] Use vilations at requried places --- src/components/MoneyRequestConfirmationList.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 7ad849282e88..038d864c4c10 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -556,7 +556,7 @@ function MoneyRequestConfirmationList({ } // Keep 'transaction' out to ensure that we autoselect the option only once // eslint-disable-next-line react-hooks/exhaustive-deps - }, [policyTagLists, policyTags, canUseViolations]); + }, [policyTagLists, policyTags]); /** */ @@ -870,14 +870,14 @@ function MoneyRequestConfirmationList({ titleStyle={styles.flex1} disabled={didConfirm} interactive={!isReadOnly} - rightLabel={isCategoryRequired ? translate('common.required') : ''} + rightLabel={isCategoryRequired && canUseViolations ? translate('common.required') : ''} /> ), shouldShow: shouldShowCategories, isSupplementary: action === CONST.IOU.ACTION.CATEGORIZE ? false : !isCategoryRequired, }, ...policyTagLists.map(({name, required}, index) => { - const isTagRequired = required === undefined ? false : canUseViolations && required; + const isTagRequired = required ?? false; return { item: ( ), shouldShow: shouldShowTags,