@@ -23,6 +23,7 @@ import {
2323 isResolvedConciergeCategoryOptions ,
2424 isResolvedConciergeDescriptionOptions ,
2525} from '@libs/ReportActionsUtils' ;
26+ import type { CreateDraftTransactionParams } from '@libs/ReportUtils' ;
2627import { createDraftTransactionAndNavigateToParticipantSelector } from '@libs/ReportUtils' ;
2728import shouldRenderAddPaymentCard from '@libs/shouldRenderAppPaymentCard' ;
2829import { dismissTrackExpenseActionableWhisper , resolveConciergeCategoryOptions , resolveConciergeDescriptionOptions } from '@userActions/Report' ;
@@ -153,74 +154,39 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
153154
154155 if ( isActionableTrackExpense ( action ) ) {
155156 const reportActionReportID = originalReportID ?? reportID ;
156- const options = [
157- {
158- text : 'actionableMentionTrackExpense.submit' ,
159- key : `${ action . reportActionID } -actionableMentionTrackExpense-submit` ,
160- onPress : ( ) => {
161- createDraftTransactionAndNavigateToParticipantSelector ( {
162- reportID : reportActionReportID ,
163- actionName : CONST . IOU . ACTION . SUBMIT ,
164- reportActionID : action . reportActionID ,
165- introSelected,
166- draftTransactionIDs,
167- activePolicy,
168- userBillingGracePeriodEnds,
169- amountOwed,
170- ownerBillingGracePeriodEnd,
171- isRestrictedToPreferredPolicy,
172- preferredPolicyID,
173- transaction : trackExpenseTransaction ,
174- currentUserAccountID : personalDetail . accountID ,
175- currentUserEmail : personalDetail . email ?? '' ,
176- } ) ;
177- } ,
157+ const baseDraftTransactionParams = {
158+ reportID : reportActionReportID ,
159+ reportActionID : action . reportActionID ,
160+ introSelected,
161+ draftTransactionIDs,
162+ activePolicy,
163+ userBillingGracePeriodEnds,
164+ amountOwed,
165+ ownerBillingGracePeriodEnd,
166+ transaction : trackExpenseTransaction ,
167+ currentUserAccountID : personalDetail . accountID ,
168+ currentUserEmail : personalDetail . email ?? '' ,
169+ } ;
170+ const TRACK_EXPENSE_ACTIONS = {
171+ submit : CONST . IOU . ACTION . SUBMIT ,
172+ categorize : CONST . IOU . ACTION . CATEGORIZE ,
173+ share : CONST . IOU . ACTION . SHARE ,
174+ } as const ;
175+ const prepareTrackExpenseButton = ( actionKey : keyof typeof TRACK_EXPENSE_ACTIONS , extraParams ?: Partial < CreateDraftTransactionParams > ) => ( {
176+ text : `actionableMentionTrackExpense.${ actionKey } ` ,
177+ key : `${ action . reportActionID } -actionableMentionTrackExpense-${ actionKey } ` ,
178+ onPress : ( ) => {
179+ createDraftTransactionAndNavigateToParticipantSelector ( {
180+ ...baseDraftTransactionParams ,
181+ ...extraParams ,
182+ actionName : TRACK_EXPENSE_ACTIONS [ actionKey ] ,
183+ } ) ;
178184 } ,
179- ] ;
185+ } ) ;
186+ const options = [ prepareTrackExpenseButton ( 'submit' , { isRestrictedToPreferredPolicy, preferredPolicyID} ) ] ;
180187
181188 if ( Permissions . canUseTrackFlows ( ) ) {
182- options . push (
183- {
184- text : 'actionableMentionTrackExpense.categorize' ,
185- key : `${ action . reportActionID } -actionableMentionTrackExpense-categorize` ,
186- onPress : ( ) => {
187- createDraftTransactionAndNavigateToParticipantSelector ( {
188- reportID : reportActionReportID ,
189- actionName : CONST . IOU . ACTION . CATEGORIZE ,
190- reportActionID : action . reportActionID ,
191- introSelected,
192- draftTransactionIDs,
193- activePolicy,
194- userBillingGracePeriodEnds,
195- amountOwed,
196- ownerBillingGracePeriodEnd,
197- transaction : trackExpenseTransaction ,
198- currentUserAccountID : personalDetail . accountID ,
199- currentUserEmail : personalDetail . email ?? '' ,
200- } ) ;
201- } ,
202- } ,
203- {
204- text : 'actionableMentionTrackExpense.share' ,
205- key : `${ action . reportActionID } -actionableMentionTrackExpense-share` ,
206- onPress : ( ) => {
207- createDraftTransactionAndNavigateToParticipantSelector ( {
208- reportID : reportActionReportID ,
209- actionName : CONST . IOU . ACTION . SHARE ,
210- reportActionID : action . reportActionID ,
211- introSelected,
212- draftTransactionIDs,
213- activePolicy,
214- userBillingGracePeriodEnds,
215- amountOwed,
216- ownerBillingGracePeriodEnd,
217- transaction : trackExpenseTransaction ,
218- currentUserAccountID : personalDetail . accountID ,
219- currentUserEmail : personalDetail . email ?? '' ,
220- } ) ;
221- } ,
222- } ,
223- ) ;
189+ options . push ( prepareTrackExpenseButton ( 'categorize' ) , prepareTrackExpenseButton ( 'share' ) ) ;
224190 }
225191 options . push ( {
226192 text : 'actionableMentionTrackExpense.nothing' ,
0 commit comments