Skip to content

Commit 4850783

Browse files
francoislOSBotify
authored andcommitted
Merge pull request #52434 from Expensify/revert-PR-51445
[CP Staging] Revert "Show search action buttons" (cherry picked from commit 9be236c) (CP triggered by francoisl)
1 parent 0c86cb6 commit 4850783

18 files changed

+67
-334
lines changed

src/CONST.ts

-3
Original file line numberDiff line numberDiff line change
@@ -5861,9 +5861,6 @@ const CONST = {
58615861
ACTION_TYPES: {
58625862
VIEW: 'view',
58635863
REVIEW: 'review',
5864-
SUBMIT: 'submit',
5865-
APPROVE: 'approve',
5866-
PAY: 'pay',
58675864
DONE: 'done',
58685865
PAID: 'paid',
58695866
},

src/components/Search/SearchPageHeader.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function SearchPageHeader({queryJSON, hash}: SearchPageHeaderProps) {
182182
return;
183183
}
184184

185-
const reportIDList = selectedReports?.filter((report) => !!report) ?? [];
185+
const reportIDList = (selectedReports?.filter((report) => !!report) as string[]) ?? [];
186186
SearchActions.exportSearchItemsToCSV(
187187
{query: status, jsonQuery: JSON.stringify(queryJSON), reportIDList, transactionIDList: selectedTransactionsKeys, policyIDs: [activeWorkspaceID ?? '']},
188188
() => {

src/components/Search/types.ts

-8
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ type SelectedTransactionInfo = {
2424
/** Model of selected results */
2525
type SelectedTransactions = Record<string, SelectedTransactionInfo>;
2626

27-
/** Model of payment data used by Search bulk actions */
28-
type PaymentData = {
29-
reportID: string;
30-
amount: number;
31-
paymentType: ValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
32-
};
33-
3427
type SortOrder = ValueOf<typeof CONST.SEARCH.SORT_ORDER>;
3528
type SearchColumnType = ValueOf<typeof CONST.SEARCH.TABLE_COLUMNS>;
3629
type ExpenseSearchStatus = ValueOf<typeof CONST.SEARCH.STATUS.EXPENSE>;
@@ -124,6 +117,5 @@ export type {
124117
TripSearchStatus,
125118
ChatSearchStatus,
126119
SearchAutocompleteResult,
127-
PaymentData,
128120
SearchAutocompleteQueryRange,
129121
};

src/components/SelectionList/Search/ActionCell.tsx

+14-29
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Badge from '@components/Badge';
44
import Button from '@components/Button';
55
import * as Expensicons from '@components/Icon/Expensicons';
66
import useLocalize from '@hooks/useLocalize';
7-
import useNetwork from '@hooks/useNetwork';
87
import useStyleUtils from '@hooks/useStyleUtils';
98
import useTheme from '@hooks/useTheme';
109
import useThemeStyles from '@hooks/useThemeStyles';
@@ -16,9 +15,6 @@ import type {SearchTransactionAction} from '@src/types/onyx/SearchResults';
1615
const actionTranslationsMap: Record<SearchTransactionAction, TranslationPaths> = {
1716
view: 'common.view',
1817
review: 'common.review',
19-
submit: 'common.submit',
20-
approve: 'iou.approve',
21-
pay: 'iou.pay',
2218
done: 'common.done',
2319
paid: 'iou.settledExpensify',
2420
};
@@ -30,23 +26,13 @@ type ActionCellProps = {
3026
goToItem: () => void;
3127
isChildListItem?: boolean;
3228
parentAction?: string;
33-
isLoading?: boolean;
3429
};
3530

36-
function ActionCell({
37-
action = CONST.SEARCH.ACTION_TYPES.VIEW,
38-
isLargeScreenWidth = true,
39-
isSelected = false,
40-
goToItem,
41-
isChildListItem = false,
42-
parentAction = '',
43-
isLoading = false,
44-
}: ActionCellProps) {
31+
function ActionCell({action = CONST.SEARCH.ACTION_TYPES.VIEW, isLargeScreenWidth = true, isSelected = false, goToItem, isChildListItem = false, parentAction = ''}: ActionCellProps) {
4532
const {translate} = useLocalize();
4633
const theme = useTheme();
4734
const styles = useThemeStyles();
4835
const StyleUtils = useStyleUtils();
49-
const {isOffline} = useNetwork();
5036

5137
const text = translate(actionTranslationsMap[action]);
5238

@@ -75,8 +61,9 @@ function ActionCell({
7561
);
7662
}
7763

64+
const buttonInnerStyles = isSelected ? styles.buttonDefaultHovered : {};
65+
7866
if (action === CONST.SEARCH.ACTION_TYPES.VIEW || shouldUseViewAction) {
79-
const buttonInnerStyles = isSelected ? styles.buttonDefaultHovered : {};
8067
return isLargeScreenWidth ? (
8168
<Button
8269
text={translate(actionTranslationsMap[CONST.SEARCH.ACTION_TYPES.VIEW])}
@@ -90,19 +77,17 @@ function ActionCell({
9077
) : null;
9178
}
9279

93-
const buttonInnerStyles = isSelected ? styles.buttonSuccessHovered : {};
94-
return (
95-
<Button
96-
text={text}
97-
onPress={goToItem}
98-
small
99-
style={[styles.w100]}
100-
innerStyles={buttonInnerStyles}
101-
isLoading={isLoading}
102-
success
103-
isDisabled={isOffline}
104-
/>
105-
);
80+
if (action === CONST.SEARCH.ACTION_TYPES.REVIEW) {
81+
return (
82+
<Button
83+
text={text}
84+
onPress={goToItem}
85+
small
86+
style={[styles.w100]}
87+
innerStyles={buttonInnerStyles}
88+
/>
89+
);
90+
}
10691
}
10792

10893
ActionCell.displayName = 'ActionCell';

src/components/SelectionList/Search/ExpenseItemHeaderNarrow.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type ExpenseItemHeaderNarrowProps = {
2828
isDisabled?: boolean | null;
2929
isDisabledCheckbox?: boolean;
3030
handleCheckboxPress?: () => void;
31-
isLoading?: boolean;
3231
};
3332

3433
function ExpenseItemHeaderNarrow({
@@ -45,7 +44,6 @@ function ExpenseItemHeaderNarrow({
4544
isDisabled,
4645
handleCheckboxPress,
4746
text,
48-
isLoading = false,
4947
}: ExpenseItemHeaderNarrowProps) {
5048
const styles = useThemeStyles();
5149
const StyleUtils = useStyleUtils();
@@ -104,7 +102,6 @@ function ExpenseItemHeaderNarrow({
104102
goToItem={onButtonPress}
105103
isLargeScreenWidth={false}
106104
isSelected={isSelected}
107-
isLoading={isLoading}
108105
/>
109106
</View>
110107
</View>

src/components/SelectionList/Search/ReportListItem.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import {View} from 'react-native';
33
import Checkbox from '@components/Checkbox';
4-
import {useSearchContext} from '@components/Search/SearchContext';
54
import BaseListItem from '@components/SelectionList/BaseListItem';
65
import type {ListItem, ReportListItemProps, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types';
76
import Text from '@components/Text';
@@ -11,7 +10,6 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
1110
import useStyleUtils from '@hooks/useStyleUtils';
1211
import useTheme from '@hooks/useTheme';
1312
import useThemeStyles from '@hooks/useThemeStyles';
14-
import {handleActionButtonPress} from '@libs/actions/Search';
1513
import * as CurrencyUtils from '@libs/CurrencyUtils';
1614
import Navigation from '@libs/Navigation/Navigation';
1715
import variables from '@styles/variables';
@@ -71,7 +69,6 @@ function ReportListItem<TItem extends ListItem>({
7169
const styles = useThemeStyles();
7270
const {isLargeScreenWidth} = useResponsiveLayout();
7371
const StyleUtils = useStyleUtils();
74-
const {currentSearchHash} = useSearchContext();
7572

7673
const animatedHighlightStyle = useAnimatedHighlightStyle({
7774
borderRadius: variables.componentBorderRadius,
@@ -96,7 +93,7 @@ function ReportListItem<TItem extends ListItem>({
9693
];
9794

9895
const handleOnButtonPress = () => {
99-
handleActionButtonPress(currentSearchHash, reportItem, () => onSelectRow(item));
96+
onSelectRow(item);
10097
};
10198

10299
const openReportInRHP = (transactionItem: TransactionListItemType) => {
@@ -168,7 +165,6 @@ function ReportListItem<TItem extends ListItem>({
168165
action={reportItem.action}
169166
onButtonPress={handleOnButtonPress}
170167
containerStyle={[styles.ph3, styles.pt1half, styles.mb1half]}
171-
isLoading={reportItem.isActionLoading}
172168
/>
173169
)}
174170
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap3, styles.ph3, styles.pv1half]}>
@@ -203,7 +199,6 @@ function ReportListItem<TItem extends ListItem>({
203199
action={reportItem.action}
204200
goToItem={handleOnButtonPress}
205201
isSelected={item.isSelected}
206-
isLoading={reportItem.isActionLoading}
207202
/>
208203
</View>
209204
)}

src/components/SelectionList/Search/TransactionListItem.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import React from 'react';
2-
import {useSearchContext} from '@components/Search/SearchContext';
32
import BaseListItem from '@components/SelectionList/BaseListItem';
43
import type {ListItem, TransactionListItemProps, TransactionListItemType} from '@components/SelectionList/types';
54
import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle';
65
import useResponsiveLayout from '@hooks/useResponsiveLayout';
76
import useTheme from '@hooks/useTheme';
87
import useThemeStyles from '@hooks/useThemeStyles';
9-
import {handleActionButtonPress} from '@libs/actions/Search';
108
import variables from '@styles/variables';
119
import TransactionListItemRow from './TransactionListItemRow';
1210

@@ -28,7 +26,6 @@ function TransactionListItem<TItem extends ListItem>({
2826
const theme = useTheme();
2927

3028
const {isLargeScreenWidth} = useResponsiveLayout();
31-
const {currentSearchHash} = useSearchContext();
3229

3330
const listItemPressableStyle = [
3431
styles.selectionListPressableItemWrapper,
@@ -78,14 +75,13 @@ function TransactionListItem<TItem extends ListItem>({
7875
item={transactionItem}
7976
showTooltip={showTooltip}
8077
onButtonPress={() => {
81-
handleActionButtonPress(currentSearchHash, transactionItem, () => onSelectRow(item));
78+
onSelectRow(item);
8279
}}
8380
onCheckboxPress={() => onCheckboxPress?.(item)}
8481
isDisabled={!!isDisabled}
8582
canSelectMultiple={!!canSelectMultiple}
8683
isButtonSelected={item.isSelected}
8784
shouldShowTransactionCheckbox={false}
88-
isLoading={transactionItem.isActionLoading}
8985
/>
9086
</BaseListItem>
9187
);

src/components/SelectionList/Search/TransactionListItemRow.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ type TransactionListItemRowProps = {
5959
isButtonSelected?: boolean;
6060
parentAction?: string;
6161
shouldShowTransactionCheckbox?: boolean;
62-
isLoading?: boolean;
6362
};
6463

6564
const getTypeIcon = (type?: SearchTransactionType) => {
@@ -258,7 +257,6 @@ function TransactionListItemRow({
258257
isButtonSelected = false,
259258
parentAction = '',
260259
shouldShowTransactionCheckbox,
261-
isLoading = false,
262260
}: TransactionListItemRowProps) {
263261
const styles = useThemeStyles();
264262
const {isLargeScreenWidth} = useResponsiveLayout();
@@ -282,7 +280,6 @@ function TransactionListItemRow({
282280
isDisabled={item.isDisabled}
283281
isDisabledCheckbox={item.isDisabledCheckbox}
284282
handleCheckboxPress={onCheckboxPress}
285-
isLoading={isLoading}
286283
/>
287284
)}
288285

@@ -448,7 +445,6 @@ function TransactionListItemRow({
448445
isChildListItem={isChildListItem}
449446
parentAction={parentAction}
450447
goToItem={onButtonPress}
451-
isLoading={isLoading}
452448
/>
453449
</View>
454450
</View>

src/components/SelectionList/SearchTableHeaderColumn.tsx

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
type PayMoneyRequestOnSearchParams = {
22
hash: number;
3+
paymentType: string;
34
/**
45
* Stringified JSON object with type of following structure:
5-
* Array<{reportID: string, amount: number, paymentType: string}>
6+
* Array<{reportID: string, amount: number}>
67
*/
7-
paymentData: string;
8+
reportsAndAmounts: string;
89
};
910

1011
export default PayMoneyRequestOnSearchParams;

src/libs/PolicyUtils.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import type {
2929
Tenant,
3030
} from '@src/types/onyx/Policy';
3131
import type PolicyEmployee from '@src/types/onyx/PolicyEmployee';
32-
import type {SearchPolicy} from '@src/types/onyx/SearchResults';
3332
import {isEmptyObject} from '@src/types/utils/EmptyObject';
3433
import {hasSynchronizationErrorMessage} from './actions/connections';
3534
import {getCategoryApproverRule} from './CategoryUtils';
@@ -185,7 +184,7 @@ function getPolicyBrickRoadIndicatorStatus(policy: OnyxEntry<Policy>, isConnecti
185184
return undefined;
186185
}
187186

188-
function getPolicyRole(policy: OnyxInputOrEntry<Policy> | SearchPolicy, currentUserLogin: string | undefined) {
187+
function getPolicyRole(policy: OnyxInputOrEntry<Policy>, currentUserLogin: string | undefined) {
189188
return policy?.role ?? policy?.employeeList?.[currentUserLogin ?? '-1']?.role;
190189
}
191190

@@ -219,7 +218,7 @@ const isUserPolicyAdmin = (policy: OnyxInputOrEntry<Policy>, login?: string) =>
219218
/**
220219
* Checks if the current user is an admin of the policy.
221220
*/
222-
const isPolicyAdmin = (policy: OnyxInputOrEntry<Policy> | SearchPolicy, currentUserLogin?: string): boolean => getPolicyRole(policy, currentUserLogin) === CONST.POLICY.ROLE.ADMIN;
221+
const isPolicyAdmin = (policy: OnyxInputOrEntry<Policy>, currentUserLogin?: string): boolean => getPolicyRole(policy, currentUserLogin) === CONST.POLICY.ROLE.ADMIN;
223222

224223
/**
225224
* Checks if the current user is of the role "user" on the policy.
@@ -380,7 +379,7 @@ function isPendingDeletePolicy(policy: OnyxEntry<Policy>): boolean {
380379
return policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
381380
}
382381

383-
function isPaidGroupPolicy(policy: OnyxEntry<Policy> | SearchPolicy): boolean {
382+
function isPaidGroupPolicy(policy: OnyxEntry<Policy>): boolean {
384383
return policy?.type === CONST.POLICY.TYPE.TEAM || policy?.type === CONST.POLICY.TYPE.CORPORATE;
385384
}
386385

@@ -405,7 +404,7 @@ function isTaxTrackingEnabled(isPolicyExpenseChat: boolean, policy: OnyxEntry<Po
405404
* Checks if policy's scheduled submit / auto reporting frequency is "instant".
406405
* Note: Free policies have "instant" submit always enabled.
407406
*/
408-
function isInstantSubmitEnabled(policy: OnyxInputOrEntry<Policy> | SearchPolicy): boolean {
407+
function isInstantSubmitEnabled(policy: OnyxInputOrEntry<Policy>): boolean {
409408
return policy?.autoReporting === true && policy?.autoReportingFrequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT;
410409
}
411410

@@ -435,7 +434,7 @@ function getCorrectedAutoReportingFrequency(policy: OnyxInputOrEntry<Policy>): V
435434
/**
436435
* Checks if policy's approval mode is "optional", a.k.a. "Submit & Close"
437436
*/
438-
function isSubmitAndClose(policy: OnyxInputOrEntry<Policy> | SearchPolicy): boolean {
437+
function isSubmitAndClose(policy: OnyxInputOrEntry<Policy>): boolean {
439438
return policy?.approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL;
440439
}
441440

0 commit comments

Comments
 (0)