Skip to content

Commit

Permalink
Merge pull request #44503 from Expensify/cmartins-sortReportsByDate
Browse files Browse the repository at this point in the history
Sort reports by created date
  • Loading branch information
mountiny authored Jul 3, 2024
2 parents 631976a + 4eb5699 commit 55546bb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const searchTypeToItemMap: SearchTypeToItemMap = {
listItem: ReportListItem,
getSections: getReportSections,
// sorting for ReportItems not yet implemented
getSortedSections: (data) => data,
getSortedSections: getSortedReportData,
},
};

Expand Down Expand Up @@ -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<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

0 comments on commit 55546bb

Please sign in to comment.