@@ -17,6 +17,7 @@ import Navigation from './Navigation/Navigation';
17
17
import Permissions from './Permissions' ;
18
18
import * as PersonalDetailsUtils from './PersonalDetailsUtils' ;
19
19
import * as PhoneNumber from './PhoneNumber' ;
20
+ import * as PolicyUtils from './PolicyUtils' ;
20
21
import * as ReportActionUtils from './ReportActionsUtils' ;
21
22
import * as ReportUtils from './ReportUtils' ;
22
23
import * as TaskUtils from './TaskUtils' ;
@@ -945,19 +946,23 @@ function getCategoryListSections(categories, recentlyUsedCategories, selectedOpt
945
946
* @returns {Array<Object> }
946
947
*/
947
948
function getTagsOptions ( tags ) {
948
- return _ . map ( tags , ( tag ) => ( {
949
- text : tag . name ,
950
- keyForList : tag . name ,
951
- searchText : tag . name ,
952
- tooltipText : tag . name ,
953
- isDisabled : ! tag . enabled ,
954
- } ) ) ;
949
+ return _ . map ( tags , ( tag ) => {
950
+ // This is to remove unnecessary escaping backslash in tag name sent from backend.
951
+ const cleanedName = PolicyUtils . getCleanedTagName ( tag . name ) ;
952
+ return {
953
+ text : cleanedName ,
954
+ keyForList : tag . name ,
955
+ searchText : tag . name ,
956
+ tooltipText : cleanedName ,
957
+ isDisabled : ! tag . enabled ,
958
+ } ;
959
+ } ) ;
955
960
}
956
961
957
962
/**
958
963
* Build the section list for tags
959
964
*
960
- * @param {Object[] } rawTags
965
+ * @param {Object[] } tags
961
966
* @param {String } tags[].name
962
967
* @param {Boolean } tags[].enabled
963
968
* @param {String[] } recentlyUsedTags
@@ -967,14 +972,8 @@ function getTagsOptions(tags) {
967
972
* @param {Number } maxRecentReportsToShow
968
973
* @returns {Array<Object> }
969
974
*/
970
- function getTagListSections ( rawTags , recentlyUsedTags , selectedOptions , searchInputValue , maxRecentReportsToShow ) {
975
+ function getTagListSections ( tags , recentlyUsedTags , selectedOptions , searchInputValue , maxRecentReportsToShow ) {
971
976
const tagSections = [ ] ;
972
- const tags = _ . map ( rawTags , ( tag ) => {
973
- // This is to remove unnecessary escaping backslash in tag name sent from backend.
974
- const tagName = tag . name && tag . name . replace ( / \\ { 1 , 2 } : / g, ':' ) ;
975
-
976
- return { ...tag , name : tagName } ;
977
- } ) ;
978
977
const sortedTags = sortTags ( tags ) ;
979
978
const enabledTags = _ . filter ( sortedTags , ( tag ) => tag . enabled ) ;
980
979
const numberOfTags = _ . size ( enabledTags ) ;
@@ -999,7 +998,7 @@ function getTagListSections(rawTags, recentlyUsedTags, selectedOptions, searchIn
999
998
}
1000
999
1001
1000
if ( ! _ . isEmpty ( searchInputValue ) ) {
1002
- const searchTags = _ . filter ( enabledTags , ( tag ) => tag . name . toLowerCase ( ) . includes ( searchInputValue . toLowerCase ( ) ) ) ;
1001
+ const searchTags = _ . filter ( enabledTags , ( tag ) => PolicyUtils . getCleanedTagName ( tag . name . toLowerCase ( ) ) . includes ( searchInputValue . toLowerCase ( ) ) ) ;
1003
1002
1004
1003
tagSections . push ( {
1005
1004
// "Search" section
0 commit comments