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
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6330,6 +6330,7 @@ const CONST = {
REPORTS: 'reports',
FROM: 'from',
CARD: 'card',
WITHDRAWAL_ID: 'withdrawal-id',
},
BOOLEAN: {
YES: 'yes',
Expand Down
20 changes: 2 additions & 18 deletions src/components/Search/SearchContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useCallback, useContext, useMemo, useRef, useState} from 'react';
import {isMoneyRequestReport} from '@libs/ReportUtils';
import {isTransactionCardGroupListItemType, isTransactionListItemType, isTransactionMemberGroupListItemType, isTransactionReportGroupListItemType} from '@libs/SearchUIUtils';
import {isTransactionListItemType, isTransactionReportGroupListItemType} from '@libs/SearchUIUtils';
import type {SearchKey} from '@libs/SearchUIUtils';
import CONST from '@src/CONST';
import type ChildrenProps from '@src/types/utils/ChildrenProps';
Expand Down Expand Up @@ -79,23 +79,7 @@ function SearchContextProvider({children}: ChildrenProps) {
selectedReports = data
.filter((item) => isMoneyRequestReport(item) && item.transactions.length > 0 && item.transactions.every(({keyForList}) => selectedTransactions[keyForList]?.isSelected))
.map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));
}

if (data.length && data.every(isTransactionMemberGroupListItemType)) {
selectedReports = data

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whyd we remove all of these?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because we can't select any transactions on these groups, since we don't return them?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's the reason. The above code can't get tested until we start returning transaction and align on the export functionality (e.g. if you select a group that only lists 50 transactions but it have more than that, should we only export the 50? How can the user know what he is only downloading a portion of the data, etc.)

.flatMap((item) => item.transactions)
.filter(({keyForList}) => !!keyForList && selectedTransactions[keyForList]?.isSelected)
.map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));
}

if (data.length && data.every(isTransactionCardGroupListItemType)) {
selectedReports = data
.flatMap((item) => item.transactions)
.filter(({keyForList}) => !!keyForList && selectedTransactions[keyForList]?.isSelected)
.map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));
}

if (data.length && data.every(isTransactionListItemType)) {
} else if (data.length && data.every(isTransactionListItemType)) {
selectedReports = data
.filter(({keyForList}) => !!keyForList && selectedTransactions[keyForList]?.isSelected)
.map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));
Expand Down
9 changes: 4 additions & 5 deletions src/components/Search/SearchPageHeader/SearchFiltersBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import SingleSelectPopup from '@components/Search/FilterDropdowns/SingleSelectPo
import UserSelectPopup from '@components/Search/FilterDropdowns/UserSelectPopup';
import {useSearchContext} from '@components/Search/SearchContext';
import type {SearchDateValues} from '@components/Search/SearchDatePresetFilterBase';
import type {SearchDateFilterKeys, SearchGroupBy, SearchQueryJSON, SingularSearchStatus} from '@components/Search/types';
import type {SearchDateFilterKeys, SearchQueryJSON, SingularSearchStatus} from '@components/Search/types';
import SearchFiltersSkeleton from '@components/Skeletons/SearchFiltersSkeleton';
import useAdvancedSearchFilters from '@hooks/useAdvancedSearchFilters';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -396,12 +396,11 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
const filters = useMemo<FilterItem[]>(() => {
const fromValue = filterFormValues.from?.map((accountID) => personalDetails?.[accountID]?.displayName ?? accountID) ?? [];

const shouldDisplayGroupByFilter = groupBy?.value === CONST.SEARCH.GROUP_BY.FROM || groupBy?.value === CONST.SEARCH.GROUP_BY.CARD;
const shouldDisplayGroupCurrencyFilter = (groupBy?.value === CONST.SEARCH.GROUP_BY.FROM || groupBy?.value === CONST.SEARCH.GROUP_BY.CARD) && hasMultipleOutputCurrency;
const shouldDisplayGroupByFilter = !!groupBy?.value && groupBy?.value !== CONST.SEARCH.GROUP_BY.REPORTS;
const shouldDisplayGroupCurrencyFilter = shouldDisplayGroupByFilter && hasMultipleOutputCurrency;
const shouldDisplayFeedFilter = feedOptions.length > 1 && !!filterFormValues.feed;
const shouldDisplayPostedFilter = !!filterFormValues.feed && (!!filterFormValues.postedOn || !!filterFormValues.postedAfter || !!filterFormValues.postedBefore);
// We'll refactor this to use a const in https://github.com/Expensify/App/issues/68227
const shouldDisplayWithdrawalTypeFilter = groupBy?.value === ('withdrawalID' as SearchGroupBy) && !!filterFormValues.withdrawalType;
const shouldDisplayWithdrawalTypeFilter = groupBy?.value === CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID && !!filterFormValues.withdrawalType;
const shouldDisplayWithdrawnFilter = !!filterFormValues.withdrawnOn || !!filterFormValues.withdrawnAfter || !!filterFormValues.withdrawnBefore;

const filterList = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ function TransactionGroupListItem<TItem extends ListItem>({
canSelectMultiple={canSelectMultiple}
/>
),
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: (
// Will be implemented as part of https://github.com/Expensify/App/pull/66078
<View />
),
};

if (!groupBy) {
Expand Down
14 changes: 13 additions & 1 deletion src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ import type CONST from '@src/CONST';
import type {PersonalDetailsList, Policy, Report, TransactionViolation} from '@src/types/onyx';
import type {Attendee, SplitExpense} from '@src/types/onyx/IOU';
import type {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon';
import type {SearchCardGroup, SearchMemberGroup, SearchPersonalDetails, SearchReport, SearchReportAction, SearchTask, SearchTransaction} from '@src/types/onyx/SearchResults';
import type {
SearchCardGroup,
SearchMemberGroup,
SearchPersonalDetails,
SearchReport,
SearchReportAction,
SearchTask,
SearchTransaction,
SearchWithdrawalIDGroup,
} from '@src/types/onyx/SearchResults';
import type {ReceiptErrors} from '@src/types/onyx/Transaction';
import type Transaction from '@src/types/onyx/Transaction';
import type ChildrenProps from '@src/types/utils/ChildrenProps';
Expand Down Expand Up @@ -339,6 +348,8 @@ type TransactionMemberGroupListItemType = TransactionGroupListItemType & {groupe

type TransactionCardGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.CARD} & SearchPersonalDetails & SearchCardGroup;

type TransactionWithdrawalIDGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID} & SearchPersonalDetails & SearchWithdrawalIDGroup;

type ListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
/** The section list item */
item: TItem;
Expand Down Expand Up @@ -916,6 +927,7 @@ export type {
TransactionReportGroupListItemType,
TransactionMemberGroupListItemType,
TransactionCardGroupListItemType,
TransactionWithdrawalIDGroupListItemType,
Section,
SectionListDataType,
SectionWithIndexOffset,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useAdvancedSearchFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function useAdvancedSearchFilters() {
const shouldDisplayCardFilter = shouldDisplayFilter(Object.keys(allCards).length, areCardsEnabled);
const shouldDisplayTaxFilter = shouldDisplayFilter(Object.keys(taxRates).length, areTaxEnabled);
const shouldDisplayWorkspaceFilter = workspaces.some((section) => section.data.length !== 0);
const shouldDisplayGroupByFilter = groupBy === CONST.SEARCH.GROUP_BY.FROM || groupBy === CONST.SEARCH.GROUP_BY.CARD;
const shouldDisplayGroupByFilter = !!groupBy && groupBy !== CONST.SEARCH.GROUP_BY.REPORTS;

let currentType = searchAdvancedFilters?.type ?? CONST.SEARCH.DATA_TYPES.EXPENSE;

Expand Down
7 changes: 4 additions & 3 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6082,9 +6082,10 @@ const translations = {
billable: 'Abrechenbar',
reimbursable: 'Erstattungsfähig',
groupBy: {
reports: 'Bericht',
from: 'Von',
card: 'Karte',
[CONST.SEARCH.GROUP_BY.REPORTS]: 'Bericht',
[CONST.SEARCH.GROUP_BY.FROM]: 'Von',
[CONST.SEARCH.GROUP_BY.CARD]: 'Karte',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'Auszahlungs-ID',
},
feed: 'Feed',
withdrawalType: {
Expand Down
7 changes: 4 additions & 3 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6057,9 +6057,10 @@ const translations = {
billable: 'Billable',
reimbursable: 'Reimbursable',
groupBy: {
reports: 'Report', // s77rt use singular key name
from: 'From',
card: 'Card',
[CONST.SEARCH.GROUP_BY.REPORTS]: 'Report',
[CONST.SEARCH.GROUP_BY.FROM]: 'From',
[CONST.SEARCH.GROUP_BY.CARD]: 'Card',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'Withdrawal ID',
},
feed: 'Feed',
withdrawalType: {
Expand Down
7 changes: 4 additions & 3 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6077,9 +6077,10 @@ const translations = {
billable: 'Facturable',
reimbursable: 'Reembolsable',
groupBy: {
reports: 'Informe',
from: 'De',
card: 'Tarjeta',
[CONST.SEARCH.GROUP_BY.REPORTS]: 'Informe',
[CONST.SEARCH.GROUP_BY.FROM]: 'De',
[CONST.SEARCH.GROUP_BY.CARD]: 'Tarjeta',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID de retiro',
},
feed: 'Feed',
withdrawalType: {
Expand Down
7 changes: 4 additions & 3 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6094,9 +6094,10 @@ const translations = {
billable: 'Facturable',
reimbursable: 'Remboursable',
groupBy: {
reports: 'Rapport',
from: 'De',
card: 'Carte',
[CONST.SEARCH.GROUP_BY.REPORTS]: 'Rapport',
[CONST.SEARCH.GROUP_BY.FROM]: 'De',
[CONST.SEARCH.GROUP_BY.CARD]: 'Carte',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID de retrait',
},
feed: 'Flux',
withdrawalType: {
Expand Down
7 changes: 4 additions & 3 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6097,9 +6097,10 @@ const translations = {
billable: 'Fatturabile',
reimbursable: 'Rimborsabile',
groupBy: {
reports: 'Rapporto',
from: 'Da',
card: 'Carta',
[CONST.SEARCH.GROUP_BY.REPORTS]: 'Rapporto',
[CONST.SEARCH.GROUP_BY.FROM]: 'Da',
[CONST.SEARCH.GROUP_BY.CARD]: 'Carta',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID di prelievo',
},
feed: 'Feed',
withdrawalType: {
Expand Down
7 changes: 4 additions & 3 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6055,9 +6055,10 @@ const translations = {
billable: 'ビラブル',
reimbursable: '払い戻し可能',
groupBy: {
reports: '報告',
from: 'から',
card: 'カード',
[CONST.SEARCH.GROUP_BY.REPORTS]: '報告',
[CONST.SEARCH.GROUP_BY.FROM]: 'から',
[CONST.SEARCH.GROUP_BY.CARD]: 'カード',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '出金ID',
},
feed: 'フィード',
withdrawalType: {
Expand Down
7 changes: 4 additions & 3 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6090,9 +6090,10 @@ const translations = {
billable: 'Factureerbaar',
reimbursable: 'Vergoedbaar',
groupBy: {
reports: 'Verslag',
from: 'Van',
card: 'Kaart',
[CONST.SEARCH.GROUP_BY.REPORTS]: 'Verslag',
[CONST.SEARCH.GROUP_BY.FROM]: 'Van',
[CONST.SEARCH.GROUP_BY.CARD]: 'Kaart',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'Opname-ID',
},
feed: 'Feed',
withdrawalType: {
Expand Down
7 changes: 4 additions & 3 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6075,9 +6075,10 @@ const translations = {
billable: 'Podlegające fakturowaniu',
reimbursable: 'Podlegające zwrotowi',
groupBy: {
reports: 'Raport',
from: 'Od',
card: 'Karta',
[CONST.SEARCH.GROUP_BY.REPORTS]: 'Raport',
[CONST.SEARCH.GROUP_BY.FROM]: 'Od',
[CONST.SEARCH.GROUP_BY.CARD]: 'Karta',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'Identyfikator wypłaty',
},
feed: 'Kanal',
withdrawalType: {
Expand Down
7 changes: 4 additions & 3 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6089,9 +6089,10 @@ const translations = {
billable: 'Faturável',
reimbursable: 'Reembolsável',
groupBy: {
reports: 'Relatório',
from: 'De',
card: 'Cartão',
[CONST.SEARCH.GROUP_BY.REPORTS]: 'Relatório',
[CONST.SEARCH.GROUP_BY.FROM]: 'De',
[CONST.SEARCH.GROUP_BY.CARD]: 'Cartão',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID de retirada',
},
feed: 'Feed',
withdrawalType: {
Expand Down
7 changes: 4 additions & 3 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5974,9 +5974,10 @@ const translations = {
billable: '可计费的',
reimbursable: '可报销的',
groupBy: {
reports: '报告',
from: '从',
card: '卡片',
[CONST.SEARCH.GROUP_BY.REPORTS]: '报告',
[CONST.SEARCH.GROUP_BY.FROM]: '从',
[CONST.SEARCH.GROUP_BY.CARD]: '卡片',
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '提现ID',
},
feed: '通道',
withdrawalType: {
Expand Down
33 changes: 33 additions & 0 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import type {
TransactionListItemType,
TransactionMemberGroupListItemType,
TransactionReportGroupListItemType,
TransactionWithdrawalIDGroupListItemType,
} from '@components/SelectionList/types';
import * as Expensicons from '@src/components/Icon/Expensicons';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -637,6 +638,13 @@ function isTransactionCardGroupListItemType(item: ListItem): item is Transaction
return isTransactionGroupListItemType(item) && 'groupedBy' in item && item.groupedBy === CONST.SEARCH.GROUP_BY.CARD;
}

/**
* Type guard that checks if something is a TransactionWithdrawalIDGroupListItemType
*/
function isTransactionWithdrawalIDGroupListItemType(item: ListItem): item is TransactionWithdrawalIDGroupListItemType {
return isTransactionGroupListItemType(item) && 'groupedBy' in item && item.groupedBy === CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID;
}

/**
* Type guard that checks if something is a TransactionListItemType
*/
Expand Down Expand Up @@ -1427,6 +1435,17 @@ function getCardSections(data: OnyxTypes.SearchResults['data']): TransactionCard
return Object.values(cardSections);
}

/**
* @private
* Organizes data into List Sections grouped by card for display, for the TransactionWithdrawalIDGroupListItemType of Search Results.
*
* Do not use directly, use only via `getSections()` facade.
*/
function getWithdrawalIDSections(data: OnyxTypes.SearchResults['data']): TransactionWithdrawalIDGroupListItemType[] {
// Will be implemented as part of https://github.com/Expensify/App/pull/66078
return data ? [] : [];
}

/**
* Returns the appropriate list item component based on the type and status of the search data.
*/
Expand Down Expand Up @@ -1474,6 +1493,8 @@ function getSections(
return getMemberSections(data);
case CONST.SEARCH.GROUP_BY.CARD:
return getCardSections(data);
case CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID:
return getWithdrawalIDSections(data);
}
}

Expand Down Expand Up @@ -1509,6 +1530,8 @@ function getSortedSections(
return getSortedMemberData(data as TransactionMemberGroupListItemType[], localeCompare);
case CONST.SEARCH.GROUP_BY.CARD:
return getSortedCardData(data as TransactionCardGroupListItemType[], localeCompare);
case CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID:
return getSortedWithdrawalIDData(data as TransactionWithdrawalIDGroupListItemType[]);
}
}

Expand Down Expand Up @@ -1617,6 +1640,15 @@ function getSortedCardData(data: TransactionCardGroupListItemType[], localeCompa
return data.sort((a, b) => localeCompare(a.displayName ?? a.login ?? '', b.displayName ?? b.login ?? ''));
}

/**
* @private
* Sorts report sections based on a specified column and sort order.
*/
function getSortedWithdrawalIDData(data: TransactionWithdrawalIDGroupListItemType[]) {
// Will be implemented as part of https://github.com/Expensify/App/pull/66078
return data ? [] : [];
}

/**
* @private
* Sorts report actions sections based on a specified column and sort order.
Expand Down Expand Up @@ -1998,6 +2030,7 @@ export {
isTransactionReportGroupListItemType,
isTransactionMemberGroupListItemType,
isTransactionCardGroupListItemType,
isTransactionWithdrawalIDGroupListItemType,
isSearchResultsEmpty,
isTransactionListItemType,
isReportActionListItemType,
Expand Down
27 changes: 26 additions & 1 deletion src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,30 @@ type SearchCardGroup = {
lastFourPAN: string;
};

/** Model of withdrawal ID grouped search result */
type SearchWithdrawalIDGroup = {
/** Withdrawal ID */
entryID: number;

/** Number of transactions */
count: number;

/** Total value of transactions */
total: number;

/** Currency of total value */
currency: string;

/** Masked account number */
accountNumber: string;

/** Bank name */
addressName: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be bankName after the BE PR is merged

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being handled in #66078


/** When the withdrawal completed */
debitPosted: string;
};

/** Types of searchable transactions */
type SearchTransactionType = ValueOf<typeof CONST.SEARCH.TRANSACTION_TYPE>;

Expand All @@ -526,7 +550,7 @@ type SearchResults = {
PrefixedRecord<typeof ONYXKEYS.COLLECTION.POLICY, SearchPolicy> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, TransactionViolation[]> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, ReportNameValuePairs> &
PrefixedRecord<typeof CONST.SEARCH.GROUP_PREFIX, SearchMemberGroup | SearchCardGroup>;
PrefixedRecord<typeof CONST.SEARCH.GROUP_PREFIX, SearchMemberGroup | SearchCardGroup | SearchWithdrawalIDGroup>;

/** Whether search data is being fetched from server */
isLoading?: boolean;
Expand All @@ -552,4 +576,5 @@ export type {
SearchResultsInfo,
SearchMemberGroup,
SearchCardGroup,
SearchWithdrawalIDGroup,
};
Loading