diff --git a/src/components/CategoryPicker/index.js b/src/components/CategoryPicker/index.js index ef8b1d71ad1d..13abf057e4b1 100644 --- a/src/components/CategoryPicker/index.js +++ b/src/components/CategoryPicker/index.js @@ -32,6 +32,7 @@ function CategoryPicker({selectedCategory, policyCategories, policyRecentlyUsedC }, [selectedCategory]); const sections = useMemo(() => { + const validPolicyRecentlyUsedCategories = _.filter(policyRecentlyUsedCategories, (p) => !_.isEmpty(p)); const {categoryOptions} = OptionsListUtils.getFilteredOptions( {}, {}, @@ -43,7 +44,7 @@ function CategoryPicker({selectedCategory, policyCategories, policyRecentlyUsedC false, true, policyCategories, - policyRecentlyUsedCategories, + validPolicyRecentlyUsedCategories, false, ); diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 2c046bfc2a24..36277216f87c 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -482,7 +482,10 @@ function getMoneyRequestInformation( // For now it only uses the first tag of the policy, since multi-tags are not yet supported const tagListKey = _.first(_.keys(policyTags)); const uniquePolicyRecentlyUsedTags = recentlyUsedPolicyTags ? _.filter(recentlyUsedPolicyTags[tagListKey], (recentlyUsedPolicyTag) => recentlyUsedPolicyTag !== tag) : []; - optimisticPolicyRecentlyUsedTags[tagListKey] = [tag, ...uniquePolicyRecentlyUsedTags]; + if (tag) { + uniquePolicyRecentlyUsedTags.unshift(tag); + } + optimisticPolicyRecentlyUsedTags[tagListKey] = [...uniquePolicyRecentlyUsedTags]; } // If there is an existing transaction (which is the case for distance requests), then the data from the existing transaction