@@ -17,6 +17,7 @@ import * as ReportUtils from '../../libs/ReportUtils';
17
17
import * as OptionsListUtils from '../../libs/OptionsListUtils' ;
18
18
import * as ReportActionsUtils from '../../libs/ReportActionsUtils' ;
19
19
import * as StyleUtils from '../../styles/StyleUtils' ;
20
+ import * as PolicyUtils from '../../libs/PolicyUtils' ;
20
21
import CONST from '../../CONST' ;
21
22
import * as Expensicons from '../Icon/Expensicons' ;
22
23
import iouReportPropTypes from '../../pages/iouReportPropTypes' ;
@@ -32,6 +33,7 @@ import * as TransactionUtils from '../../libs/TransactionUtils';
32
33
import OfflineWithFeedback from '../OfflineWithFeedback' ;
33
34
import categoryPropTypes from '../categoryPropTypes' ;
34
35
import SpacerView from '../SpacerView' ;
36
+ import tagPropTypes from '../tagPropTypes' ;
35
37
36
38
const propTypes = {
37
39
/** The report currently being looked at */
@@ -53,6 +55,9 @@ const propTypes = {
53
55
/** The transaction associated with the transactionThread */
54
56
transaction : transactionPropTypes ,
55
57
58
+ /** Collection of tags attached to a policy */
59
+ policyTags : tagPropTypes ,
60
+
56
61
...withCurrentUserPersonalDetailsPropTypes ,
57
62
} ;
58
63
@@ -65,9 +70,10 @@ const defaultProps = {
65
70
currency : CONST . CURRENCY . USD ,
66
71
comment : { comment : '' } ,
67
72
} ,
73
+ policyTags : { } ,
68
74
} ;
69
75
70
- function MoneyRequestView ( { betas , report , parentReport, policyCategories, shouldShowHorizontalRule, transaction} ) {
76
+ function MoneyRequestView ( { report , betas , parentReport, policyCategories, shouldShowHorizontalRule, transaction, policyTags } ) {
71
77
const { isSmallScreenWidth} = useWindowDimensions ( ) ;
72
78
const { translate} = useLocalize ( ) ;
73
79
@@ -80,6 +86,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should
80
86
comment : transactionDescription ,
81
87
merchant : transactionMerchant ,
82
88
category : transactionCategory ,
89
+ tag : transactionTag ,
83
90
} = ReportUtils . getTransactionDetails ( transaction ) ;
84
91
const isEmptyMerchant =
85
92
transactionMerchant === '' || transactionMerchant === CONST . TRANSACTION . UNKNOWN_MERCHANT || transactionMerchant === CONST . TRANSACTION . PARTIAL_TRANSACTION_MERCHANT ;
@@ -89,8 +96,14 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should
89
96
const canEdit = ReportUtils . canEditMoneyRequest ( parentReportAction ) ;
90
97
// A flag for verifying that the current report is a sub-report of a workspace chat
91
98
const isPolicyExpenseChat = useMemo ( ( ) => ReportUtils . isPolicyExpenseChat ( ReportUtils . getRootParentReport ( report ) ) , [ report ] ) ;
92
- // A flag for showing categories
99
+
100
+ // Fetches only the first tag, for now
101
+ const policyTag = PolicyUtils . getTag ( policyTags ) ;
102
+ const policyTagsList = lodashGet ( policyTag , 'tags' , { } ) ;
103
+
104
+ // Flags for showing categories and tags
93
105
const shouldShowCategory = isPolicyExpenseChat && Permissions . canUseCategories ( betas ) && ( transactionCategory || OptionsListUtils . hasEnabledOptions ( lodashValues ( policyCategories ) ) ) ;
106
+ const shouldShowTag = isPolicyExpenseChat && Permissions . canUseTags ( betas ) && ( transactionTag || OptionsListUtils . hasEnabledOptions ( lodashValues ( policyTagsList ) ) ) ;
94
107
95
108
let description = `${ translate ( 'iou.amount' ) } • ${ translate ( 'iou.cash' ) } ` ;
96
109
if ( isSettled ) {
@@ -200,6 +213,18 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should
200
213
/>
201
214
</ OfflineWithFeedback >
202
215
) }
216
+ { shouldShowTag && (
217
+ < OfflineWithFeedback pendingAction = { lodashGet ( transaction , 'pendingFields.tag' ) || lodashGet ( transaction , 'pendingAction' ) } >
218
+ < MenuItemWithTopDescription
219
+ description = { lodashGet ( policyTag , 'name' , translate ( 'common.tag' ) ) }
220
+ title = { transactionTag }
221
+ interactive = { canEdit }
222
+ shouldShowRightIcon = { canEdit }
223
+ titleStyle = { styles . flex1 }
224
+ onPress = { ( ) => Navigation . navigate ( ROUTES . EDIT_REQUEST . getRoute ( report . reportID , CONST . EDIT_REQUEST_FIELD . TAG ) ) }
225
+ />
226
+ </ OfflineWithFeedback >
227
+ ) }
203
228
< SpacerView
204
229
shouldShow = { shouldShowHorizontalRule }
205
230
style = { [ shouldShowHorizontalRule ? styles . reportHorizontalRule : { } ] }
@@ -237,5 +262,8 @@ export default compose(
237
262
return `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ;
238
263
} ,
239
264
} ,
265
+ policyTags : {
266
+ key : ( { report} ) => `${ ONYXKEYS . COLLECTION . POLICY_TAGS } ${ report . policyID } ` ,
267
+ } ,
240
268
} ) ,
241
269
) ( MoneyRequestView ) ;
0 commit comments