@@ -36,7 +36,7 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
3636import getPlatform from '@libs/getPlatform' ;
3737import { getTotalAmountForIOUReportPreviewButton } from '@libs/MoneyRequestReportUtils' ;
3838import Navigation from '@libs/Navigation/Navigation' ;
39- import type { KYCFlowEvent , TriggerKYCFlow } from '@libs/PaymentUtils' ;
39+ import type { KYCFlowEvent , TriggerKYCFlow , WorkspacePolicyPaymentOption } from '@libs/PaymentUtils' ;
4040import { selectPaymentType } from '@libs/PaymentUtils' ;
4141import { sortPoliciesByName } from '@libs/PolicyUtils' ;
4242import { getFilteredReportActionsForReportView , hasRequestFromCurrentAccount } from '@libs/ReportActionsUtils' ;
@@ -55,7 +55,6 @@ import {canApproveIOU, canIOUBePaid as canIOUBePaidAction} from '@userActions/IO
5555import CONST from '@src/CONST' ;
5656import ONYXKEYS from '@src/ONYXKEYS' ;
5757import type { Route } from '@src/ROUTES' ;
58- import type * as OnyxTypes from '@src/types/onyx' ;
5958import type { PaymentMethodType } from '@src/types/onyx/OriginalMessage' ;
6059
6160type MoneyReportHeaderSecondaryActionsProps = {
@@ -232,25 +231,26 @@ function MoneyReportHeaderSecondaryActions({reportID, primaryAction, isReportInS
232231
233232 const expensifyIcons = useMemoizedLazyExpensifyIcons ( [ 'Info' , 'Cash' , 'ArrowRight' , 'Building' ] ) ;
234233
235- const buildPaymentSubMenuItems = ( onWorkspaceSelected : ( workspacePolicy : OnyxTypes . Policy ) => void ) : PopoverMenuItem [ ] => {
236- if ( ! workspacePolicyOptions . length ) {
237- return Object . values ( paymentButtonOptions ) ;
238- }
239- const result : PopoverMenuItem [ ] = [ ] ;
234+ // Build PAY action sub-items. Workspace-policy entries carry the policy as data and have no onSelected;
235+ // MoneyReportHeaderKYCDropdown picks them up via onSubItemSelected where triggerKYCFlow is in scope.
236+ const paymentSubMenuItems : PopoverMenuItem [ ] = [ ] ;
237+ if ( ! workspacePolicyOptions . length ) {
238+ paymentSubMenuItems . push ( ...Object . values ( paymentButtonOptions ) ) ;
239+ } else {
240240 for ( const opt of Object . values ( paymentButtonOptions ) ) {
241- result . push ( opt ) ;
241+ paymentSubMenuItems . push ( opt ) ;
242242 if ( opt . value === CONST . IOU . PAYMENT_TYPE . EXPENSIFY ) {
243243 for ( const wp of workspacePolicyOptions ) {
244- result . push ( {
244+ const workspacePolicyItem : WorkspacePolicyPaymentOption = {
245245 text : translate ( 'iou.payWithPolicy' , truncate ( wp . name , { length : CONST . ADDITIONAL_ALLOWED_CHARACTERS } ) , '' ) ,
246246 icon : expensifyIcons . Building ,
247- onSelected : ( ) => onWorkspaceSelected ( wp ) ,
248- } ) ;
247+ workspacePolicy : wp ,
248+ } ;
249+ paymentSubMenuItems . push ( workspacePolicyItem ) ;
249250 }
250251 }
251252 }
252- return result ;
253- } ;
253+ }
254254
255255 // Domain hooks
256256 const lifecycleActions = useLifecycleActions ( {
@@ -337,10 +337,7 @@ function MoneyReportHeaderSecondaryActions({reportID, primaryAction, isReportInS
337337 value : CONST . REPORT . SECONDARY_ACTIONS . PAY ,
338338 backButtonText : translate ( 'iou.settlePayment' , totalAmount ) ,
339339 sentryLabel : CONST . SENTRY_LABEL . MORE_MENU . PAY ,
340- // eslint-disable-next-line react-hooks/refs -- ref is only accessed inside the callback (event handler), not during render
341- subMenuItems : buildPaymentSubMenuItems ( ( wp ) => {
342- kycWallRef . current ?. continueAction ?.( { policy : wp } ) ;
343- } ) ,
340+ subMenuItems : paymentSubMenuItems ,
344341 } ,
345342 } ;
346343
0 commit comments