@@ -2,6 +2,7 @@ import type {TextStyle, ViewStyle} from 'react-native';
22import Onyx from 'react-native-onyx' ;
33import type { OnyxCollection } from 'react-native-onyx' ;
44import type { ValueOf } from 'type-fest' ;
5+ import type { LocaleContextProps } from '@components/LocaleContextProvider' ;
56import DotLottieAnimations from '@components/LottieAnimations' ;
67import type DotLottieAnimation from '@components/LottieAnimations/types' ;
78import type { MenuItemWithLink } from '@components/MenuItemList' ;
@@ -51,7 +52,6 @@ import {convertToDisplayString} from './CurrencyUtils';
5152import DateUtils from './DateUtils' ;
5253import { isDevelopment } from './Environment/Environment' ;
5354import interceptAnonymousUser from './interceptAnonymousUser' ;
54- import localeCompare from './LocaleCompare' ;
5555import { formatPhoneNumber } from './LocalePhoneNumber' ;
5656import { translateLocal } from './Localize' ;
5757import Navigation from './Navigation/Navigation' ;
@@ -1292,38 +1292,39 @@ function getSortedSections(
12921292 type : SearchDataTypes ,
12931293 status : SearchStatus ,
12941294 data : ListItemDataType < typeof type , typeof status > ,
1295+ localeCompare : LocaleContextProps [ 'localeCompare' ] ,
12951296 sortBy ?: SearchColumnType ,
12961297 sortOrder ?: SortOrder ,
12971298 groupBy ?: SearchGroupBy ,
12981299) {
12991300 if ( type === CONST . SEARCH . DATA_TYPES . CHAT ) {
1300- return getSortedReportActionData ( data as ReportActionListItemType [ ] ) ;
1301+ return getSortedReportActionData ( data as ReportActionListItemType [ ] , localeCompare ) ;
13011302 }
13021303 if ( type === CONST . SEARCH . DATA_TYPES . TASK ) {
1303- return getSortedTaskData ( data as TaskListItemType [ ] , sortBy , sortOrder ) ;
1304+ return getSortedTaskData ( data as TaskListItemType [ ] , localeCompare , sortBy , sortOrder ) ;
13041305 }
13051306
13061307 if ( groupBy ) {
13071308 // Disabling the default-case lint rule here is actually safer as this forces us to make the switch cases exhaustive
13081309 // eslint-disable-next-line default-case
13091310 switch ( groupBy ) {
13101311 case CONST . SEARCH . GROUP_BY . REPORTS :
1311- return getSortedReportData ( data as TransactionReportGroupListItemType [ ] ) ;
1312+ return getSortedReportData ( data as TransactionReportGroupListItemType [ ] , localeCompare ) ;
13121313 case CONST . SEARCH . GROUP_BY . MEMBERS :
13131314 return getSortedMemberData ( data as TransactionMemberGroupListItemType [ ] ) ;
13141315 case CONST . SEARCH . GROUP_BY . CARDS :
13151316 return getSortedCardData ( data as TransactionCardGroupListItemType [ ] ) ;
13161317 }
13171318 }
13181319
1319- return getSortedTransactionData ( data as TransactionListItemType [ ] , sortBy , sortOrder ) ;
1320+ return getSortedTransactionData ( data as TransactionListItemType [ ] , localeCompare , sortBy , sortOrder ) ;
13201321}
13211322
13221323/**
13231324 * Compares two values based on a specified sorting order and column.
13241325 * Handles both string and numeric comparisons, with special handling for absolute values when sorting by total amount.
13251326 */
1326- function compareValues ( a : unknown , b : unknown , sortOrder : SortOrder , sortBy : string ) : number {
1327+ function compareValues ( a : unknown , b : unknown , sortOrder : SortOrder , sortBy : string , localeCompare : LocaleContextProps [ 'localeCompare' ] ) : number {
13271328 const isAsc = sortOrder === CONST . SEARCH . SORT_ORDER . ASC ;
13281329
13291330 if ( a === undefined || b === undefined ) {
@@ -1347,7 +1348,7 @@ function compareValues(a: unknown, b: unknown, sortOrder: SortOrder, sortBy: str
13471348 * @private
13481349 * Sorts transaction sections based on a specified column and sort order.
13491350 */
1350- function getSortedTransactionData ( data : TransactionListItemType [ ] , sortBy ?: SearchColumnType , sortOrder ?: SortOrder ) {
1351+ function getSortedTransactionData ( data : TransactionListItemType [ ] , localeCompare : LocaleContextProps [ 'localeCompare' ] , sortBy ?: SearchColumnType , sortOrder ?: SortOrder ) {
13511352 if ( ! sortBy || ! sortOrder ) {
13521353 return data ;
13531354 }
@@ -1362,11 +1363,11 @@ function getSortedTransactionData(data: TransactionListItemType[], sortBy?: Sear
13621363 const aValue = sortingProperty === 'comment' ? a . comment ?. comment : a [ sortingProperty as keyof TransactionListItemType ] ;
13631364 const bValue = sortingProperty === 'comment' ? b . comment ?. comment : b [ sortingProperty as keyof TransactionListItemType ] ;
13641365
1365- return compareValues ( aValue , bValue , sortOrder , sortingProperty ) ;
1366+ return compareValues ( aValue , bValue , sortOrder , sortingProperty , localeCompare ) ;
13661367 } ) ;
13671368}
13681369
1369- function getSortedTaskData ( data : TaskListItemType [ ] , sortBy ?: SearchColumnType , sortOrder ?: SortOrder ) {
1370+ function getSortedTaskData ( data : TaskListItemType [ ] , localeCompare : LocaleContextProps [ 'localeCompare' ] , sortBy ?: SearchColumnType , sortOrder ?: SortOrder ) {
13701371 if ( ! sortBy || ! sortOrder ) {
13711372 return data ;
13721373 }
@@ -1381,17 +1382,17 @@ function getSortedTaskData(data: TaskListItemType[], sortBy?: SearchColumnType,
13811382 const aValue = a [ sortingProperty as keyof TaskListItemType ] ;
13821383 const bValue = b [ sortingProperty as keyof TaskListItemType ] ;
13831384
1384- return compareValues ( aValue , bValue , sortOrder , sortingProperty ) ;
1385+ return compareValues ( aValue , bValue , sortOrder , sortingProperty , localeCompare ) ;
13851386 } ) ;
13861387}
13871388
13881389/**
13891390 * @private
13901391 * Sorts report sections based on a specified column and sort order.
13911392 */
1392- function getSortedReportData ( data : TransactionReportGroupListItemType [ ] ) {
1393+ function getSortedReportData ( data : TransactionReportGroupListItemType [ ] , localeCompare : LocaleContextProps [ 'localeCompare' ] ) {
13931394 for ( const report of data ) {
1394- report . transactions = getSortedTransactionData ( report . transactions , CONST . SEARCH . TABLE_COLUMNS . DATE , CONST . SEARCH . SORT_ORDER . DESC ) ;
1395+ report . transactions = getSortedTransactionData ( report . transactions , localeCompare , CONST . SEARCH . TABLE_COLUMNS . DATE , CONST . SEARCH . SORT_ORDER . DESC ) ;
13951396 }
13961397 return data . sort ( ( a , b ) => {
13971398 const aNewestTransaction = a . transactions ?. at ( 0 ) ?. modifiedCreated ? a . transactions ?. at ( 0 ) ?. modifiedCreated : a . transactions ?. at ( 0 ) ?. created ;
@@ -1425,7 +1426,7 @@ function getSortedCardData(data: TransactionCardGroupListItemType[]) {
14251426 * @private
14261427 * Sorts report actions sections based on a specified column and sort order.
14271428 */
1428- function getSortedReportActionData ( data : ReportActionListItemType [ ] ) {
1429+ function getSortedReportActionData ( data : ReportActionListItemType [ ] , localeCompare : LocaleContextProps [ 'localeCompare' ] ) {
14291430 return data . sort ( ( a , b ) => {
14301431 const aValue = a ?. created ;
14311432 const bValue = b ?. created ;
0 commit comments