From b24edbe4e445f107d71e4a5181fc4df71de63811 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Thu, 8 Feb 2024 09:28:34 +0100 Subject: [PATCH 1/3] Fix bug with Payment option reverts back --- src/components/SettlementButton.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/SettlementButton.tsx b/src/components/SettlementButton.tsx index 058def7a34ad..e5adc4f6e4c4 100644 --- a/src/components/SettlementButton.tsx +++ b/src/components/SettlementButton.tsx @@ -2,6 +2,7 @@ import React, {useEffect, useMemo} from 'react'; import type {GestureResponderEvent, StyleProp, ViewStyle} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; +import sortBy from 'lodash/sortBy'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import * as ReportUtils from '@libs/ReportUtils'; @@ -182,7 +183,7 @@ function SettlementButton({ // Put the preferred payment method to the front of the array, so it's shown as default if (paymentMethod) { - return buttonOptions.sort((method) => (method.value === paymentMethod ? 0 : 1)); + return sortBy(buttonOptions, (method) => (method.value === paymentMethod ? 0 : 1)); } return buttonOptions; // We don't want to reorder the options when the preferred payment method changes while the button is still visible From 0789c2ec7fe1c34f21fe31be3db0355aefcfe0ae Mon Sep 17 00:00:00 2001 From: Yauheni Date: Thu, 8 Feb 2024 11:09:52 +0100 Subject: [PATCH 2/3] Fix lint issue --- src/components/SettlementButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SettlementButton.tsx b/src/components/SettlementButton.tsx index e5adc4f6e4c4..36fa47f55946 100644 --- a/src/components/SettlementButton.tsx +++ b/src/components/SettlementButton.tsx @@ -1,8 +1,8 @@ +import sortBy from 'lodash/sortBy'; import React, {useEffect, useMemo} from 'react'; import type {GestureResponderEvent, StyleProp, ViewStyle} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; -import sortBy from 'lodash/sortBy'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import * as ReportUtils from '@libs/ReportUtils'; From dd050fcecaa422889f915997f9c6b64af427f002 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Thu, 8 Feb 2024 13:14:58 +0100 Subject: [PATCH 3/3] Fix comment --- src/components/SettlementButton.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/SettlementButton.tsx b/src/components/SettlementButton.tsx index 36fa47f55946..cb84ab849b1f 100644 --- a/src/components/SettlementButton.tsx +++ b/src/components/SettlementButton.tsx @@ -1,4 +1,3 @@ -import sortBy from 'lodash/sortBy'; import React, {useEffect, useMemo} from 'react'; import type {GestureResponderEvent, StyleProp, ViewStyle} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; @@ -183,7 +182,7 @@ function SettlementButton({ // Put the preferred payment method to the front of the array, so it's shown as default if (paymentMethod) { - return sortBy(buttonOptions, (method) => (method.value === paymentMethod ? 0 : 1)); + return buttonOptions.sort((method) => (method.value === paymentMethod ? -1 : 0)); } return buttonOptions; // We don't want to reorder the options when the preferred payment method changes while the button is still visible