-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix/35134: Auto select category and tag #35862
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
Changes from all commits
6db0aa7
61f9d38
142587c
5a3120b
d5833a6
2842e16
6241f85
7c5fa7f
7729a29
7820222
b7f38fc
4142436
3085c9b
014531d
2be9fa8
8e43ae2
71bf809
0854392
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import {useIsFocused} from '@react-navigation/native'; | ||
| import {format} from 'date-fns'; | ||
| import Str from 'expensify-common/lib/str'; | ||
| import {isUndefined} from 'lodash'; | ||
| import lodashGet from 'lodash/get'; | ||
| import PropTypes from 'prop-types'; | ||
| import React, {useCallback, useEffect, useMemo, useReducer, useRef, useState} from 'react'; | ||
|
|
@@ -490,6 +491,31 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ | |
| IOU.setMoneyRequestMerchant(transaction.transactionID, distanceMerchant, true); | ||
| }, [isDistanceRequestWithPendingRoute, hasRoute, distance, unit, rate, currency, translate, toLocaleDigit, isDistanceRequest, transaction]); | ||
|
|
||
| // Auto select the category if there is only one enabled category and it is required | ||
| useEffect(() => { | ||
| const enabledCategories = _.filter(policyCategories, (category) => category.enabled); | ||
| if (iouCategory || !shouldShowCategories || enabledCategories.length !== 1 || !isCategoryRequired) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jjcoffee With tags, we not only have
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dukenv0307 Ah good point! For multi-level tags I think we need to use the Regarding my previous comment, I think it probably makes sense to just add |
||
| return; | ||
| } | ||
| IOU.setMoneyRequestCategory(transaction.transactionID, enabledCategories[0].name); | ||
| }, [iouCategory, shouldShowCategories, policyCategories, transaction, isCategoryRequired]); | ||
|
|
||
| // Auto select the tag if there is only one enabled tag and it is required | ||
| useEffect(() => { | ||
| let updatedTagsString = TransactionUtils.getTag(transaction); | ||
| policyTagLists.forEach((tagList, index) => { | ||
| const enabledTags = _.filter(tagList.tags, (tag) => tag.enabled); | ||
| const isTagListRequired = isUndefined(tagList.required) ? false : tagList.required && canUseViolations; | ||
|
puneetlath marked this conversation as resolved.
|
||
| if (!isTagListRequired || enabledTags.length !== 1 || TransactionUtils.getTag(transaction, index)) { | ||
| return; | ||
| } | ||
| updatedTagsString = IOUUtils.insertTagIntoTransactionTagsString(updatedTagsString, enabledTags[0] ? enabledTags[0].name : '', index); | ||
| }); | ||
| if (updatedTagsString !== TransactionUtils.getTag(transaction) && updatedTagsString) { | ||
| IOU.setMoneyRequestTag(transaction.transactionID, updatedTagsString); | ||
| } | ||
| }, [policyTagLists, transaction, policyTags, isTagRequired, canUseViolations]); | ||
|
|
||
| /** | ||
| * @param {Object} option | ||
| */ | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.