@@ -3,7 +3,7 @@ import {View} from 'react-native';
3
3
import { useOnyx } from 'react-native-onyx' ;
4
4
import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
5
5
import ScreenWrapper from '@components/ScreenWrapper' ;
6
- import SelectionList from '@components/SelectionList ' ;
6
+ import ScrollView from '@components/ScrollView ' ;
7
7
import type { ListItem } from '@components/SelectionList/types' ;
8
8
import Text from '@components/Text' ;
9
9
import useLocalize from '@hooks/useLocalize' ;
@@ -37,28 +37,31 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet
37
37
setWorkspaceRequiresCategory ( policyID , value ) ;
38
38
} ;
39
39
40
- const { sections} = useMemo ( ( ) => {
41
- if ( ! ( currentPolicy && currentPolicy . mccGroup ) ) {
42
- return { sections : [ { data : [ ] } ] } ;
40
+ const policyMccGroup = currentPolicy ?. mccGroup ;
41
+ const listItems = useMemo ( ( ) => {
42
+ let data : ListItem [ ] = [ ] ;
43
+
44
+ if ( policyMccGroup ) {
45
+ data = Object . entries ( policyMccGroup ) . map (
46
+ ( [ mccKey , mccGroup ] ) =>
47
+ ( {
48
+ categoryID : mccGroup . category ,
49
+ keyForList : mccKey ,
50
+ groupID : mccKey ,
51
+ policyID,
52
+ tabIndex : - 1 ,
53
+ } as ListItem ) ,
54
+ ) ;
43
55
}
44
56
45
- return {
46
- sections : [
47
- {
48
- data : Object . entries ( currentPolicy . mccGroup ) . map (
49
- ( [ mccKey , mccGroup ] ) =>
50
- ( {
51
- categoryID : mccGroup . category ,
52
- keyForList : mccKey ,
53
- groupID : mccKey ,
54
- policyID,
55
- tabIndex : - 1 ,
56
- } as ListItem ) ,
57
- ) ,
58
- } ,
59
- ] ,
60
- } ;
61
- } , [ currentPolicy , policyID ] ) ;
57
+ return data . map ( ( item ) => (
58
+ < SpendCategorySelectorListItem
59
+ key = { item . keyForList }
60
+ item = { item }
61
+ showTooltip
62
+ />
63
+ ) ) ;
64
+ } , [ policyMccGroup , policyID ] ) ;
62
65
63
66
const hasEnabledOptions = OptionsListUtils . hasEnabledOptions ( policyCategories ?? { } ) ;
64
67
const isToggleDisabled = ! policy ?. areCategoriesEnabled || ! hasEnabledOptions || isConnectedToAccounting ;
@@ -89,18 +92,14 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet
89
92
shouldPlaceSubtitleBelowSwitch
90
93
/>
91
94
< View style = { [ styles . containerWithSpaceBetween ] } >
92
- { ! ! currentPolicy && sections [ 0 ] . data . length > 0 && (
93
- < SelectionList
94
- headerContent = {
95
- < View style = { [ styles . mh5 , styles . mt2 , styles . mb1 ] } >
96
- < Text style = { [ styles . headerText ] } > { translate ( 'workspace.categories.defaultSpendCategories' ) } </ Text >
97
- < Text style = { [ styles . mt1 , styles . lh20 ] } > { translate ( 'workspace.categories.spendCategoriesDescription' ) } </ Text >
98
- </ View >
99
- }
100
- sections = { sections }
101
- ListItem = { SpendCategorySelectorListItem }
102
- onSelectRow = { ( ) => { } }
103
- />
95
+ { ! ! currentPolicy && listItems && (
96
+ < >
97
+ < View style = { [ styles . mh5 , styles . mt2 , styles . mb1 ] } >
98
+ < Text style = { [ styles . headerText ] } > { translate ( 'workspace.categories.defaultSpendCategories' ) } </ Text >
99
+ < Text style = { [ styles . mt1 , styles . lh20 ] } > { translate ( 'workspace.categories.spendCategoriesDescription' ) } </ Text >
100
+ </ View >
101
+ < ScrollView > { listItems } </ ScrollView >
102
+ </ >
104
103
) }
105
104
</ View >
106
105
</ ScreenWrapper >
0 commit comments