@@ -15,8 +15,6 @@ import useLocalize from '@hooks/useLocalize';
15
15
import useThemeStyles from '@hooks/useThemeStyles' ;
16
16
import type { ObjectType , OnyxDataType } from '@libs/DebugUtils' ;
17
17
import DebugUtils from '@libs/DebugUtils' ;
18
- import * as PolicyUtils from '@libs/PolicyUtils' ;
19
- import * as TagsOptionsListUtils from '@libs/TagsOptionsListUtils' ;
20
18
import Debug from '@userActions/Debug' ;
21
19
import type CONST from '@src/CONST' ;
22
20
import type { TranslationPaths } from '@src/languages/types' ;
@@ -34,6 +32,13 @@ type DebugDetailsProps = {
34
32
/** The report or report action data to be displayed and editted. */
35
33
data : OnyxEntry < Report > | OnyxEntry < ReportAction > | OnyxEntry < Transaction > | OnyxEntry < TransactionViolation > ;
36
34
35
+ /** Whether the provided policy has enabled tags */
36
+ policyHasEnabledTags ?: boolean ;
37
+
38
+ /** ID of the provided policy */
39
+ policyID ?: string ;
40
+
41
+ /** Metadata UI */
37
42
children ?: React . ReactNode ;
38
43
39
44
/** Callback to be called when user saves the debug data. */
@@ -47,13 +52,10 @@ type DebugDetailsProps = {
47
52
validate : ( key : any , value : string ) => void ;
48
53
} ;
49
54
50
- function DebugDetails ( { formType, data, children, onSave, onDelete, validate} : DebugDetailsProps ) {
55
+ function DebugDetails ( { formType, data, policyHasEnabledTags , policyID , children, onSave, onDelete, validate} : DebugDetailsProps ) {
51
56
const { translate} = useLocalize ( ) ;
52
57
const styles = useThemeStyles ( ) ;
53
58
const [ formDraftData ] = useOnyx ( ONYXKEYS . FORMS . DEBUG_DETAILS_FORM_DRAFT ) ;
54
- const [ report ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ ( data as OnyxEntry < Transaction > ) ?. reportID ?? '' } ` ) ;
55
- const [ policyTags ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY_TAGS } ${ report ?. policyID } ` ) ;
56
- const policyTagLists = useMemo ( ( ) => PolicyUtils . getTagLists ( policyTags ) , [ policyTags ] ) ;
57
59
const booleanFields = useMemo (
58
60
( ) =>
59
61
Object . entries ( data ?? { } )
@@ -66,13 +68,13 @@ function DebugDetails({formType, data, children, onSave, onDelete, validate}: De
66
68
Object . entries ( data ?? { } )
67
69
. filter ( ( entry ) : entry is [ string , string ] => {
68
70
// Tag picker needs to be hidden when the policy has no tags available to pick
69
- if ( entry [ 0 ] === TRANSACTION_FORM_INPUT_IDS . TAG && ! TagsOptionsListUtils . hasEnabledTags ( policyTagLists ) ) {
71
+ if ( entry [ 0 ] === TRANSACTION_FORM_INPUT_IDS . TAG && ! policyHasEnabledTags ) {
70
72
return false ;
71
73
}
72
74
return DETAILS_CONSTANT_FIELDS [ formType ] . some ( ( { fieldName} ) => fieldName === entry [ 0 ] ) ;
73
75
} )
74
76
. sort ( ( a , b ) => a [ 0 ] . localeCompare ( b [ 0 ] ) ) ,
75
- [ data , formType , policyTagLists ] ,
77
+ [ data , formType , policyHasEnabledTags ] ,
76
78
) ;
77
79
const numberFields = useMemo (
78
80
( ) =>
@@ -209,7 +211,7 @@ function DebugDetails({formType, data, children, onSave, onDelete, validate}: De
209
211
name = { key }
210
212
shouldSaveDraft
211
213
defaultValue = { String ( value ) }
212
- policyID = { report ?. policyID }
214
+ policyID = { policyID }
213
215
/>
214
216
) ) }
215
217
{ constantFields . length === 0 && < Text style = { [ styles . textNormalThemeText , styles . ph5 ] } > { translate ( 'debug.none' ) } </ Text > }
@@ -248,9 +250,7 @@ function DebugDetails({formType, data, children, onSave, onDelete, validate}: De
248
250
danger
249
251
large
250
252
text = { translate ( 'common.delete' ) }
251
- onPress = { ( ) => {
252
- onDelete ( ) ;
253
- } }
253
+ onPress = { onDelete }
254
254
/>
255
255
</ View >
256
256
</ FormProvider >
0 commit comments