Skip to content

Commit d752e6a

Browse files
authored
Merge pull request Expensify#68017 from Expensify/vit-revert63501
[CP Staging] Revert "Merge pull request Expensify#63501 from Expensify/youssef_auto_show_hide_columns"
2 parents 9af748b + 321d985 commit d752e6a

19 files changed

Lines changed: 201 additions & 544 deletions

src/CONST/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,6 @@ const CONST = {
12951295
RECEIPT: 'receipt',
12961296
DATE: 'date',
12971297
MERCHANT: 'merchant',
1298-
DESCRIPTION: 'description',
12991298
FROM: 'from',
13001299
TO: 'to',
13011300
CATEGORY: 'category',
@@ -6488,9 +6487,6 @@ const CONST = {
64886487
UNAPPROVED_CASH: 'unapprovedCash',
64896488
UNAPPROVED_CARD: 'unapprovedCard',
64906489
},
6491-
ANIMATION: {
6492-
FADE_DURATION: 200,
6493-
},
64946490
},
64956491

64966492
EXPENSE: {

src/components/MoneyRequestReportView/MoneyRequestReportTableHeader.tsx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ type ColumnConfig = {
1313
isColumnSortable?: boolean;
1414
};
1515

16+
const shouldShowColumnConfig: Record<SortableColumnName, (isIOUReport: boolean) => boolean> = {
17+
[CONST.SEARCH.TABLE_COLUMNS.RECEIPT]: () => true,
18+
[CONST.SEARCH.TABLE_COLUMNS.TYPE]: () => true,
19+
[CONST.SEARCH.TABLE_COLUMNS.DATE]: () => true,
20+
[CONST.SEARCH.TABLE_COLUMNS.MERCHANT]: () => true,
21+
[CONST.SEARCH.TABLE_COLUMNS.CATEGORY]: (isIOUReport) => !isIOUReport,
22+
[CONST.SEARCH.TABLE_COLUMNS.TAG]: (isIOUReport) => !isIOUReport,
23+
[CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: () => true,
24+
[CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: () => true,
25+
[CONST.SEARCH.TABLE_COLUMNS.IN]: () => false,
26+
[CONST.SEARCH.TABLE_COLUMNS.FROM]: () => false,
27+
[CONST.SEARCH.TABLE_COLUMNS.TO]: () => false,
28+
[CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION]: () => false,
29+
[CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: () => false,
30+
[CONST.SEARCH.TABLE_COLUMNS.ACTION]: () => false,
31+
[CONST.SEARCH.TABLE_COLUMNS.TITLE]: () => false,
32+
[CONST.SEARCH.TABLE_COLUMNS.ASSIGNEE]: () => false,
33+
};
34+
1635
const columnConfig: ColumnConfig[] = [
1736
{
1837
columnName: CONST.SEARCH.TABLE_COLUMNS.RECEIPT,
@@ -32,10 +51,6 @@ const columnConfig: ColumnConfig[] = [
3251
columnName: CONST.SEARCH.TABLE_COLUMNS.MERCHANT,
3352
translationKey: 'common.merchant',
3453
},
35-
{
36-
columnName: CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION,
37-
translationKey: 'common.description',
38-
},
3954
{
4055
columnName: CONST.SEARCH.TABLE_COLUMNS.CATEGORY,
4156
translationKey: 'common.category',
@@ -63,19 +78,22 @@ type SearchTableHeaderProps = {
6378
amountColumnSize: TableColumnSize;
6479
taxAmountColumnSize: TableColumnSize;
6580
shouldShowSorting: boolean;
66-
columns: SortableColumnName[];
81+
isIOUReport: boolean;
6782
};
6883

69-
function MoneyRequestReportTableHeader({sortBy, sortOrder, onSortPress, dateColumnSize, shouldShowSorting, amountColumnSize, taxAmountColumnSize, columns}: SearchTableHeaderProps) {
84+
function MoneyRequestReportTableHeader({sortBy, sortOrder, onSortPress, dateColumnSize, shouldShowSorting, isIOUReport, amountColumnSize, taxAmountColumnSize}: SearchTableHeaderProps) {
7085
const styles = useThemeStyles();
7186

7287
const shouldShowColumn = useCallback(
7388
(columnName: SortableColumnName) => {
74-
return columns.includes(columnName);
89+
const shouldShowFun = shouldShowColumnConfig[columnName];
90+
if (!shouldShowFun) {
91+
return false;
92+
}
93+
return shouldShowFun(isIOUReport);
7594
},
76-
[columns],
95+
[isIOUReport],
7796
);
78-
7997
return (
8098
<View style={[styles.dFlex, styles.flex5]}>
8199
<SortableTableHeader

src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import React, {useEffect, useRef} from 'react';
22
import type {View} from 'react-native';
3-
import type {ValueOf} from 'type-fest';
43
import {getButtonRole} from '@components/Button/utils';
54
import OfflineWithFeedback from '@components/OfflineWithFeedback';
65
import {PressableWithFeedback} from '@components/Pressable';
76
import type {TableColumnSize} from '@components/Search/types';
8-
import type {SortableColumnName} from '@components/SelectionList/types';
97
import TransactionItemRow from '@components/TransactionItemRow';
108
import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle';
119
import useLocalize from '@hooks/useLocalize';
@@ -20,6 +18,17 @@ import CONST from '@src/CONST';
2018
import type {Report} from '@src/types/onyx';
2119
import type {TransactionWithOptionalHighlight} from './MoneyRequestReportTransactionList';
2220

21+
const allReportColumns = [
22+
CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT,
23+
CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE,
24+
CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE,
25+
CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT,
26+
CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY,
27+
CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAG,
28+
CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS,
29+
CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT,
30+
];
31+
2332
type MoneyRequestReportTransactionItemProps = {
2433
/** The transaction that is being displayed */
2534
transaction: TransactionWithOptionalHighlight;
@@ -51,16 +60,12 @@ type MoneyRequestReportTransactionItemProps = {
5160
/** The size of the tax amount column */
5261
taxAmountColumnSize: TableColumnSize;
5362

54-
/** Columns to show */
55-
columns: SortableColumnName[];
56-
5763
/** Callback function that scrolls to this transaction in case it is newly added */
5864
scrollToNewTransaction?: (offset: number) => void;
5965
};
6066

6167
function MoneyRequestReportTransactionItem({
6268
transaction,
63-
columns,
6469
report,
6570
isSelectionModeEnabled,
6671
toggleTransaction,
@@ -133,7 +138,7 @@ function MoneyRequestReportTransactionItem({
133138
shouldUseNarrowLayout={shouldUseNarrowLayout || isMediumScreenWidth}
134139
shouldShowCheckbox={!!isSelectionModeEnabled || !isSmallScreenWidth}
135140
onCheckboxPress={toggleTransaction}
136-
columns={columns as Array<ValueOf<typeof CONST.REPORT.TRANSACTION_LIST.COLUMNS>>}
141+
columns={allReportColumns}
137142
isDisabled={isPendingDelete}
138143
/>
139144
</PressableWithFeedback>

src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import {convertToDisplayString} from '@libs/CurrencyUtils';
2222
import {getThreadReportIDsForTransactions} from '@libs/MoneyRequestReportUtils';
2323
import {navigationRef} from '@libs/Navigation/Navigation';
2424
import {getIOUActionForTransactionID} from '@libs/ReportActionsUtils';
25-
import {getMoneyRequestSpendBreakdown} from '@libs/ReportUtils';
26-
import {compareValues, getColumnsToShow, isTransactionAmountTooLong, isTransactionTaxAmountTooLong} from '@libs/SearchUIUtils';
25+
import {getMoneyRequestSpendBreakdown, isIOUReport} from '@libs/ReportUtils';
26+
import {compareValues, isTransactionAmountTooLong, isTransactionTaxAmountTooLong} from '@libs/SearchUIUtils';
2727
import {getTransactionPendingAction, isTransactionPendingDelete} from '@libs/TransactionUtils';
2828
import shouldShowTransactionYear from '@libs/TransactionUtils/shouldShowTransactionYear';
2929
import Navigation from '@navigation/Navigation';
@@ -160,11 +160,6 @@ function MoneyRequestReportTransactionList({
160160
}));
161161
}, [newTransactions, sortBy, sortOrder, transactions, localeCompare]);
162162

163-
const columnsToShow = useMemo(() => {
164-
const columns = getColumnsToShow(transactions, true);
165-
return (Object.keys(columns) as SortableColumnName[]).filter((column) => columns[column]);
166-
}, [transactions]);
167-
168163
const navigateToTransaction = useCallback(
169164
(activeTransactionID: string) => {
170165
const iouAction = getIOUActionForTransactionID(reportActions, activeTransactionID);
@@ -267,7 +262,6 @@ function MoneyRequestReportTransactionList({
267262
shouldShowSorting
268263
sortBy={sortBy}
269264
sortOrder={sortOrder}
270-
columns={columnsToShow}
271265
dateColumnSize={dateColumnSize}
272266
amountColumnSize={amountColumnSize}
273267
taxAmountColumnSize={taxAmountColumnSize}
@@ -278,6 +272,7 @@ function MoneyRequestReportTransactionList({
278272

279273
setSortConfig((prevState) => ({...prevState, sortBy: selectedSortBy, sortOrder: selectedSortOrder}));
280274
}}
275+
isIOUReport={isIOUReport(report)}
281276
/>
282277
)}
283278
</View>
@@ -288,7 +283,6 @@ function MoneyRequestReportTransactionList({
288283
<MoneyRequestReportTransactionItem
289284
key={transaction.transactionID}
290285
transaction={transaction}
291-
columns={columnsToShow}
292286
report={report}
293287
isSelectionModeEnabled={isMobileSelectionModeEnabled}
294288
toggleTransaction={toggleTransaction}

src/components/Search/SearchList.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ import type ChatListItem from '@components/SelectionList/ChatListItem';
1616
import type TaskListItem from '@components/SelectionList/Search/TaskListItem';
1717
import type TransactionGroupListItem from '@components/SelectionList/Search/TransactionGroupListItem';
1818
import type TransactionListItem from '@components/SelectionList/Search/TransactionListItem';
19-
import type {
20-
ExtendedTargetedEvent,
21-
ReportActionListItemType,
22-
SortableColumnName,
23-
TaskListItemType,
24-
TransactionGroupListItemType,
25-
TransactionListItemType,
26-
} from '@components/SelectionList/types';
19+
import type {ExtendedTargetedEvent, ReportActionListItemType, TaskListItemType, TransactionGroupListItemType, TransactionListItemType} from '@components/SelectionList/types';
2720
import Text from '@components/Text';
2821
import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager';
2922
import useInitialWindowDimensions from '@hooks/useInitialWindowDimensions';
@@ -87,9 +80,6 @@ type SearchListProps = Pick<FlashListProps<SearchListItem>, 'onScroll' | 'conten
8780
/** The search query */
8881
queryJSON: SearchQueryJSON;
8982

90-
/** Columns to show */
91-
columns: SortableColumnName[];
92-
9383
/** Called when the viewability of rows changes, as defined by the viewabilityConfig prop. */
9484
onViewableItemsChanged?: (info: {changed: ViewToken[]; viewableItems: ViewToken[]}) => void;
9585

@@ -134,7 +124,6 @@ function SearchList(
134124
shouldPreventDefaultFocusOnSelectRow,
135125
shouldPreventLongPressRow,
136126
queryJSON,
137-
columns,
138127
onViewableItemsChanged,
139128
onLayout,
140129
estimatedItemSize = ITEM_HEIGHTS.NARROW_WITHOUT_DRAWER.STANDARD,
@@ -350,7 +339,6 @@ function SearchList(
350339
}}
351340
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow}
352341
queryJSONHash={hash}
353-
columns={columns}
354342
policies={policies}
355343
isDisabled={isDisabled}
356344
allReports={allReports}
@@ -371,7 +359,6 @@ function SearchList(
371359
onCheckboxPress,
372360
onSelectRow,
373361
policies,
374-
columns,
375362
hash,
376363
groupBy,
377364
setFocusedIndex,
@@ -473,7 +460,7 @@ function SearchList(
473460
onScroll={onScroll}
474461
showsVerticalScrollIndicator={false}
475462
ref={listRef}
476-
extraData={[focusedIndex, isFocused, columns]}
463+
extraData={[focusedIndex, isFocused]}
477464
onEndReached={onEndReached}
478465
onEndReachedThreshold={onEndReachedThreshold}
479466
ListFooterComponent={ListFooterComponent}

0 commit comments

Comments
 (0)