Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]: Single category and tag isn't auto selected when requesting money #41651

Merged
merged 4 commits into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function MoneyRequestConfirmationList({

const shouldDisplayMerchantError = isMerchantRequired && (shouldDisplayFieldError || formError === 'iou.error.invalidMerchant') && isMerchantEmpty;

const isCategoryRequired = canUseViolations && !!policy?.requiresCategory;
const isCategoryRequired = !!policy?.requiresCategory;
allgandalf marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
if (shouldDisplayFieldError && hasSmartScanFailed) {
Expand Down Expand Up @@ -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 ?? false;
allgandalf marked this conversation as resolved.
Show resolved Hide resolved
if (!isTagListRequired || enabledTags.length !== 1 || TransactionUtils.getTag(transaction, index)) {
return;
}
Expand All @@ -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]);

/**
*/
Expand Down Expand Up @@ -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: (
<MenuItemWithTopDescription
Expand All @@ -894,7 +894,7 @@ function MoneyRequestConfirmationList({
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!isReadOnly}
rightLabel={isTagRequired ? translate('common.required') : ''}
rightLabel={isTagRequired && canUseViolations ? translate('common.required') : ''}
/>
),
shouldShow: shouldShowTags,
Expand Down
Loading