Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const searchTypeToItemMap: SearchTypeToItemMap = {
listItem: ReportListItem,
getSections: getReportSections,
// sorting for ReportItems not yet implemented
getSortedSections: (data) => data,
getSortedSections: getSortedReportData,
},
};

Expand Down Expand Up @@ -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<RootStackParamList>);
return topmostCentralPaneRoute?.params as AuthScreensParamList['Search_Central_Pane'];
Expand Down
9 changes: 9 additions & 0 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down