diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index 5a7f514a7196..119c20179a0c 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -217,7 +217,7 @@ const searchTypeToItemMap: SearchTypeToItemMap = { listItem: ReportListItem, getSections: getReportSections, // sorting for ReportItems not yet implemented - getSortedSections: (data) => data, + getSortedSections: getSortedReportData, }, }; @@ -278,6 +278,19 @@ function getSortedTransactionData(data: TransactionListItemType[], sortBy?: Sear }); } +function getSortedReportData(data: ReportListItemType[]) { + return data.sort((a, b) => { + const aValue = a?.created; + const bValue = b?.created; + + if (aValue === undefined || bValue === undefined) { + return 0; + } + + return bValue.toLowerCase().localeCompare(aValue); + }); +} + function getSearchParams() { const topmostCentralPaneRoute = getTopmostCentralPaneRoute(navigationRef.getRootState() as State); return topmostCentralPaneRoute?.params as AuthScreensParamList['Search_Central_Pane']; diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index 62c5a1d3eb6e..89d1b6c72566 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -110,6 +110,15 @@ type SearchReport = { /** The report type */ type?: string; + /** The accountID of the report manager */ + managerID?: number; + + /** The accountID of the user who created the report */ + accountID?: number; + + /** The date the report was created */ + created?: string; + /** The action that can be performed for the report */ action?: string; };