diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index 6e6a541ccdffb..6c28bdecfd931 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -212,7 +212,7 @@ const searchTypeToItemMap: SearchTypeToItemMap = { listItem: ReportListItem, getSections: getReportSections, // sorting for ReportItems not yet implemented - getSortedSections: (data) => data, + getSortedSections: getSortedReportData, }, }; @@ -273,6 +273,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 3932752f43254..b0c2c03397616 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; };