@@ -177,8 +177,9 @@ function SettlementButton({
177
177
return [ approveButtonOption ] ;
178
178
}
179
179
180
- // To achieve the one tap pay experience we need to choose the correct payment type as default,
181
- // if user already paid for some request or expense, let's use the last payment method or use default.
180
+ // To achieve the one tap pay experience we need to choose the correct payment type as default.
181
+ // If the user has previously chosen a specific payment option or paid for some request or expense,
182
+ // let's use the last payment method or use default.
182
183
const paymentMethod = nvp_lastPaymentMethod [ policyID ] || '' ;
183
184
if ( canUseWallet ) {
184
185
buttonOptions . push ( paymentMethods [ CONST . IOU . PAYMENT_TYPE . EXPENSIFY ] ) ;
@@ -192,12 +193,14 @@ function SettlementButton({
192
193
buttonOptions . push ( approveButtonOption ) ;
193
194
}
194
195
195
- // Put the preferred payment method to the front of the array so its shown as default
196
+ // Put the preferred payment method to the front of the array, so it's shown as default
196
197
if ( paymentMethod ) {
197
198
return _ . sortBy ( buttonOptions , ( method ) => ( method . value === paymentMethod ? 0 : 1 ) ) ;
198
199
}
199
200
return buttonOptions ;
200
- } , [ currency , formattedAmount , iouReport , nvp_lastPaymentMethod , policyID , translate , shouldHidePaymentOptions , shouldShowApproveButton ] ) ;
201
+ // We don't want to reorder the options when the preferred payment method changes while the button is still visible
202
+ // eslint-disable-next-line react-hooks/exhaustive-deps
203
+ } , [ currency , formattedAmount , iouReport , policyID , translate , shouldHidePaymentOptions , shouldShowApproveButton ] ) ;
201
204
202
205
const selectPaymentType = ( event , iouPaymentType , triggerKYCFlow ) => {
203
206
if ( iouPaymentType === CONST . IOU . PAYMENT_TYPE . EXPENSIFY || iouPaymentType === CONST . IOU . PAYMENT_TYPE . VBBA ) {
@@ -235,6 +238,7 @@ function SettlementButton({
235
238
onPress = { ( event , iouPaymentType ) => selectPaymentType ( event , iouPaymentType , triggerKYCFlow ) }
236
239
pressOnEnter = { pressOnEnter }
237
240
options = { paymentButtonOptions }
241
+ onOptionSelected = { ( option ) => IOU . savePreferredPaymentMethod ( policyID , option . value ) }
238
242
style = { style }
239
243
buttonSize = { buttonSize }
240
244
anchorAlignment = { paymentMethodDropdownAnchorAlignment }
0 commit comments