Skip to content

Commit 763a99e

Browse files
authored
Merge pull request Expensify#64911 from s77rt/statement-matching
Search: Added `Card` to GROUP_BY
2 parents 187c68c + 444b47e commit 763a99e

19 files changed

Lines changed: 139 additions & 34 deletions

File tree

src/CONST/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6604,6 +6604,7 @@ const CONST = {
66046604
GROUP_BY: {
66056605
REPORTS: 'reports',
66066606
MEMBERS: 'members',
6607+
CARDS: 'cards',
66076608
},
66086609
BOOLEAN: {
66096610
YES: 'yes',

src/components/Search/SearchContext.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {useCallback, useContext, useMemo, useRef, useState} from 'react';
22
import {isMoneyRequestReport} from '@libs/ReportUtils';
3-
import {isTransactionListItemType, isTransactionMemberGroupListItemType, isTransactionReportGroupListItemType} from '@libs/SearchUIUtils';
3+
import {isTransactionCardGroupListItemType, isTransactionListItemType, isTransactionMemberGroupListItemType, isTransactionReportGroupListItemType} from '@libs/SearchUIUtils';
44
import CONST from '@src/CONST';
55
import type ChildrenProps from '@src/types/utils/ChildrenProps';
66
import type {SearchContext, SearchContextData} from './types';
@@ -76,6 +76,13 @@ function SearchContextProvider({children}: ChildrenProps) {
7676
.map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));
7777
}
7878

79+
if (data.length && data.every(isTransactionCardGroupListItemType)) {
80+
selectedReports = data
81+
.flatMap((item) => item.transactions)
82+
.filter(({keyForList}) => !!keyForList && selectedTransactions[keyForList]?.isSelected)
83+
.map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));
84+
}
85+
7986
if (data.length && data.every(isTransactionListItemType)) {
8087
selectedReports = data
8188
.filter(({keyForList}) => !!keyForList && selectedTransactions[keyForList]?.isSelected)

src/components/SelectionList/Search/MemberListItemHeader.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import Checkbox from '@components/Checkbox';
55
import type {ListItem, TransactionMemberGroupListItemType} from '@components/SelectionList/types';
66
import TextWithTooltip from '@components/TextWithTooltip';
77
import UserDetailsTooltip from '@components/UserDetailsTooltip';
8+
import useLocalize from '@hooks/useLocalize';
89
import useThemeStyles from '@hooks/useThemeStyles';
10+
import {formatPhoneNumber} from '@libs/LocalePhoneNumber';
11+
import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils';
912
import CONST from '@src/CONST';
1013

1114
type MemberListItemHeaderProps<TItem extends ListItem> = {
@@ -24,6 +27,10 @@ type MemberListItemHeaderProps<TItem extends ListItem> = {
2427

2528
function MemberListItemHeader<TItem extends ListItem>({member: memberItem, onCheckboxPress, isDisabled, canSelectMultiple}: MemberListItemHeaderProps<TItem>) {
2629
const styles = useThemeStyles();
30+
const {translate} = useLocalize();
31+
32+
const formattedDisplayName = formatPhoneNumber(getDisplayNameOrDefault(memberItem));
33+
const formattedLogin = formatPhoneNumber(memberItem.login ?? '');
2734

2835
// s77rt add total cell, action cell and collapse/expand button
2936

@@ -36,7 +43,7 @@ function MemberListItemHeader<TItem extends ListItem>({member: memberItem, onChe
3643
onPress={() => onCheckboxPress?.(memberItem as unknown as TItem)}
3744
isChecked={memberItem.isSelected}
3845
disabled={!!isDisabled || memberItem.isDisabledCheckbox}
39-
accessibilityLabel={memberItem.text ?? ''}
46+
accessibilityLabel={translate('common.select')}
4047
/>
4148
)}
4249
<View style={[styles.flexRow, styles.gap3]}>
@@ -45,18 +52,18 @@ function MemberListItemHeader<TItem extends ListItem>({member: memberItem, onChe
4552
<Avatar
4653
source={memberItem.avatar}
4754
type={CONST.ICON_TYPE_AVATAR}
48-
name={memberItem.displayName ?? memberItem.login}
55+
name={formattedDisplayName}
4956
avatarID={memberItem.accountID}
5057
/>
5158
</View>
5259
</UserDetailsTooltip>
5360
<View style={[styles.gapHalf]}>
5461
<TextWithTooltip
55-
text={memberItem.displayName ?? memberItem.login ?? ''}
62+
text={formattedDisplayName}
5663
style={[styles.optionDisplayName, styles.sidebarLinkTextBold, styles.pre]}
5764
/>
5865
<TextWithTooltip
59-
text={memberItem.login ?? ''}
66+
text={formattedLogin || formattedDisplayName}
6067
style={[styles.textLabelSupporting, styles.lh16, styles.pre]}
6168
/>
6269
</View>

src/components/SelectionList/Search/TransactionGroupListItem.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ function TransactionGroupListItem<TItem extends ListItem>({
133133
canSelectMultiple={canSelectMultiple}
134134
/>
135135
),
136+
[CONST.SEARCH.GROUP_BY.CARDS]: (
137+
// s77rt CardListItemHeader
138+
<View />
139+
),
136140
};
137141

138142
if (!groupBy) {

src/components/SelectionList/types.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import type CONST from '@src/CONST';
2525
import type {Policy, Report, TransactionViolation} from '@src/types/onyx';
2626
import type {Attendee, SplitExpense} from '@src/types/onyx/IOU';
2727
import type {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon';
28-
import type {SearchPersonalDetails, SearchReport, SearchReportAction, SearchTask, SearchTransaction} from '@src/types/onyx/SearchResults';
28+
import type {SearchCard, SearchPersonalDetails, SearchReport, SearchReportAction, SearchTask, SearchTransaction} from '@src/types/onyx/SearchResults';
2929
import type {ReceiptErrors} from '@src/types/onyx/Transaction';
3030
import type Transaction from '@src/types/onyx/Transaction';
3131
import type ChildrenProps from '@src/types/utils/ChildrenProps';
@@ -330,16 +330,17 @@ type TransactionGroupListItemType = ListItem & {
330330
transactions: TransactionListItemType[];
331331
};
332332

333-
type TransactionReportGroupListItemType = TransactionGroupListItemType &
334-
SearchReport & {
333+
type TransactionReportGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.REPORTS} & SearchReport & {
335334
/** The personal details of the user requesting money */
336335
from: SearchPersonalDetails;
337336

338337
/** The personal details of the user paying the request */
339338
to: SearchPersonalDetails;
340339
};
341340

342-
type TransactionMemberGroupListItemType = TransactionGroupListItemType & SearchPersonalDetails;
341+
type TransactionMemberGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.MEMBERS} & SearchPersonalDetails;
342+
343+
type TransactionCardGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.CARDS} & SearchPersonalDetails & SearchCard;
343344

344345
type ListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
345346
/** The section list item */
@@ -880,6 +881,7 @@ export type {
880881
TransactionGroupListItemType,
881882
TransactionReportGroupListItemType,
882883
TransactionMemberGroupListItemType,
884+
TransactionCardGroupListItemType,
883885
Section,
884886
SectionListDataType,
885887
SectionWithIndexOffset,

src/languages/de.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5770,6 +5770,7 @@ const translations = {
57705770
groupBy: {
57715771
reports: 'Bericht',
57725772
members: 'Mitglied',
5773+
cards: 'Karte',
57735774
},
57745775
},
57755776
groupBy: 'Gruppe nach',

src/languages/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5707,6 +5707,7 @@ const translations = {
57075707
groupBy: {
57085708
reports: 'Report', // s77rt use singular key name
57095709
members: 'Member', // s77rt use singular key name
5710+
cards: 'Card', // s77rt use singular key name
57105711
},
57115712
},
57125713
groupBy: 'Group by',

src/languages/es.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5760,6 +5760,7 @@ const translations = {
57605760
groupBy: {
57615761
reports: 'Informe',
57625762
members: 'Miembro',
5763+
cards: 'Tarjeta',
57635764
},
57645765
},
57655766
groupBy: 'Agrupar por',

src/languages/fr.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5780,6 +5780,7 @@ const translations = {
57805780
groupBy: {
57815781
reports: 'Rapport',
57825782
members: 'Membre',
5783+
cards: 'Carte',
57835784
},
57845785
},
57855786
groupBy: 'Groupe par',

src/languages/it.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5756,6 +5756,7 @@ const translations = {
57565756
groupBy: {
57575757
reports: 'Rapporto',
57585758
members: 'Membro',
5759+
cards: 'Carta',
57595760
},
57605761
},
57615762
groupBy: 'Gruppo per',

0 commit comments

Comments
 (0)