Skip to content

Commit

Permalink
Merge pull request #43206 from Expensify/cmartins-leaveColumnsOn
Browse files Browse the repository at this point in the history
Always show categories, tags and taxes columns
  • Loading branch information
srikarparsi authored Jun 6, 2024
2 parents 1f3658c + 3f8b47f commit 35a4f83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/components/SelectionList/SearchTableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ const SearchColumns: SearchColumnConfig[] = [
{
columnName: CONST.SEARCH_TABLE_COLUMNS.CATEGORY,
translationKey: 'common.category',
shouldShow: (data: OnyxTypes.SearchResults['data']) => SearchUtils.getShouldShowColumn(data, CONST.SEARCH_TABLE_COLUMNS.CATEGORY),
shouldShow: () => true,
},
{
columnName: CONST.SEARCH_TABLE_COLUMNS.TAG,
translationKey: 'common.tag',
shouldShow: (data: OnyxTypes.SearchResults['data']) => SearchUtils.getShouldShowColumn(data, CONST.SEARCH_TABLE_COLUMNS.TAG),
shouldShow: () => true,
},
{
columnName: CONST.SEARCH_TABLE_COLUMNS.TAX_AMOUNT,
translationKey: 'common.tax',
shouldShow: (data: OnyxTypes.SearchResults['data']) => SearchUtils.getShouldShowColumn(data, CONST.SEARCH_TABLE_COLUMNS.TAX_AMOUNT),
shouldShow: () => true,
isColumnSortable: false,
},
{
Expand Down
24 changes: 7 additions & 17 deletions src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,8 @@ function getShouldShowMerchant(data: OnyxTypes.SearchResults['data']): boolean {
});
}

function getShouldShowColumn(data: OnyxTypes.SearchResults['data'], columnName: ValueOf<typeof CONST.SEARCH_TABLE_COLUMNS>) {
return Object.values(data).some((item) => !!item[columnName]);
}

function getTransactionsSections(data: OnyxTypes.SearchResults['data']): TransactionListItemType[] {
const shouldShowMerchant = getShouldShowMerchant(data);
const shouldShowCategory = getShouldShowColumn(data, CONST.SEARCH_TABLE_COLUMNS.CATEGORY);
const shouldShowTag = getShouldShowColumn(data, CONST.SEARCH_TABLE_COLUMNS.TAG);
const shouldShowTax = getShouldShowColumn(data, CONST.SEARCH_TABLE_COLUMNS.TAX_AMOUNT);

return Object.entries(data)
.filter(([key]) => key.startsWith(ONYXKEYS.COLLECTION.TRANSACTION))
Expand All @@ -107,19 +100,16 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data']): Transac
formattedMerchant,
date,
shouldShowMerchant,
shouldShowCategory,
shouldShowTag,
shouldShowTax,
shouldShowCategory: true,
shouldShowTag: true,
shouldShowTax: true,
keyForList: transactionItem.transactionID,
};
});
}

function getReportSections(data: OnyxTypes.SearchResults['data']): ReportListItemType[] {
const shouldShowMerchant = getShouldShowMerchant(data);
const shouldShowCategory = getShouldShowColumn(data, CONST.SEARCH_TABLE_COLUMNS.CATEGORY);
const shouldShowTag = getShouldShowColumn(data, CONST.SEARCH_TABLE_COLUMNS.TAG);
const shouldShowTax = getShouldShowColumn(data, CONST.SEARCH_TABLE_COLUMNS.TAX_AMOUNT);

const reportIDToTransactions: Record<string, ReportListItemType> = {};
for (const key in data) {
Expand Down Expand Up @@ -152,9 +142,9 @@ function getReportSections(data: OnyxTypes.SearchResults['data']): ReportListIte
formattedMerchant,
date,
shouldShowMerchant,
shouldShowCategory,
shouldShowTag,
shouldShowTax,
shouldShowCategory: true,
shouldShowTag: true,
shouldShowTax: true,
keyForList: transactionItem.transactionID,
};
if (reportIDToTransactions[reportKey]?.transactions) {
Expand Down Expand Up @@ -240,5 +230,5 @@ function getSearchParams() {
return topmostCentralPaneRoute?.params as CentralPaneNavigatorParamList['Search_Central_Pane'];
}

export {getListItem, getQueryHash, getSections, getSortedSections, getShouldShowColumn, getShouldShowMerchant, getSearchType, getSearchParams};
export {getListItem, getQueryHash, getSections, getSortedSections, getShouldShowMerchant, getSearchType, getSearchParams};
export type {SearchColumnType, SortOrder};

0 comments on commit 35a4f83

Please sign in to comment.