Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3ae1698
feat: draft solution for select empty report
lorretheboy Sep 19, 2025
fbea7b5
Merge branch 'main' of https://github.com/Expensify/App into fix/70591
lorretheboy Sep 21, 2025
a409d56
fix: type err
lorretheboy Sep 21, 2025
9644d7a
fix: lint
lorretheboy Sep 21, 2025
2e808b9
fix: refactor
lorretheboy Sep 21, 2025
3d64bbc
chore: reduce duplicated code
lorretheboy Sep 21, 2025
1e05e52
feat: support delete empty report
lorretheboy Sep 21, 2025
9065324
chore: optimize
lorretheboy Sep 21, 2025
e315938
chore: merge main
lorretheboy Sep 23, 2025
27a5448
chore: resolve conflicts
lorretheboy Sep 25, 2025
8675a46
fix: resolve conflicts
lorretheboy Sep 28, 2025
4c5a607
chore: handle pending delete case
lorretheboy Sep 28, 2025
3af1876
fix: revert code
lorretheboy Sep 28, 2025
2eee88e
fix: preserve selection
lorretheboy Sep 28, 2025
d0a70a7
Merge branch 'main' of https://github.com/Expensify/App into fix/70591
lorretheboy Oct 5, 2025
f12ea0a
fix: delete state
lorretheboy Oct 5, 2025
5c13937
Merge branch 'main' of https://github.com/Expensify/App into fix/70591
lorretheboy Oct 6, 2025
7e69199
fix: refactoring code
lorretheboy Oct 6, 2025
ed1431c
fix: conflicts
lorretheboy Oct 9, 2025
fbd4eaa
fix: optimizing
lorretheboy Oct 9, 2025
8da7d1c
fix: resolve conflicts
lorretheboy Oct 14, 2025
8911336
fix: can't select empty report long press
lorretheboy Oct 14, 2025
510633d
feat: add tests
lorretheboy Oct 14, 2025
9941379
fix: tests
lorretheboy Oct 14, 2025
1d354e4
fix: conflicts
lorretheboy Oct 16, 2025
8faabda
chore: simplize test
lorretheboy Oct 16, 2025
7755873
fix: conflicts
lorretheboy Oct 16, 2025
d7cb151
fix: conflicts
lorretheboy Oct 16, 2025
c37c24d
fix: conflicts
lorretheboy Oct 16, 2025
2b13fae
fix: conflicts
lorretheboy Oct 23, 2025
f195112
feat: add UI test
lorretheboy Oct 23, 2025
71d38fd
fix: lint
lorretheboy Oct 23, 2025
9e295ea
fix: prettier
lorretheboy Oct 23, 2025
ab921e6
fix: eslint
lorretheboy Oct 23, 2025
39fd3f9
fix: conflicts
lorretheboy Oct 24, 2025
75cae1f
fix: update test
lorretheboy Oct 24, 2025
0b4f6e3
fix: conflicts
lorretheboy Oct 24, 2025
34ab596
chore: merge main
lorretheboy Oct 25, 2025
6aa527f
Merge branch 'main' of https://github.com/Expensify/App into fix/70591
lorretheboy Oct 29, 2025
959b17f
chore: update code
lorretheboy Oct 29, 2025
4884728
chore: merge main
lorretheboy Oct 30, 2025
5ceef66
chore: update condition to show abs amount
lorretheboy Oct 30, 2025
b0d085c
chore: merge main
lorretheboy Oct 30, 2025
780aac4
chore: merge latest main
lorretheboy Oct 31, 2025
139f3e7
merge main
lorretheboy Nov 1, 2025
ca1bdcd
merge main
lorretheboy Nov 5, 2025
905062a
fix: deps
lorretheboy Nov 5, 2025
b5269e5
fix: test
lorretheboy Nov 5, 2025
e28a9d7
fix: prettier
lorretheboy Nov 5, 2025
d82eb3e
chore: merge main
lorretheboy Nov 6, 2025
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
50 changes: 34 additions & 16 deletions src/components/Search/SearchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,37 @@ function SearchList({
}
return data;
}, [data, groupBy, type]);
const flattenedItemsWithoutPendingDelete = useMemo(() => flattenedItems.filter((t) => t?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE), [flattenedItems]);
Comment thread
lorretheboy marked this conversation as resolved.
Resolved

const selectedItemsLength = useMemo(
() =>
flattenedItems.reduce((acc, item) => {
return item?.isSelected ? acc + 1 : acc;
}, 0),
[flattenedItems],
);

const emptyReports = useMemo(() => {
if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT && isTransactionGroupListItemArray(data)) {
return data.filter((item) => item.transactions.length === 0);
}
return [];
}, [data, type]);

const selectedItemsLength = useMemo(() => {
const selectedTransactions = flattenedItems.reduce((acc, item) => {
return acc + (item?.isSelected ? 1 : 0);
}, 0);

if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT && isTransactionGroupListItemArray(data)) {
const selectedEmptyReports = emptyReports.reduce((acc, item) => {
return acc + (item.isSelected ? 1 : 0);
}, 0);

return selectedEmptyReports + selectedTransactions;
}

return selectedTransactions;
}, [flattenedItems, type, data, emptyReports]);

const totalItems = useMemo(() => {
if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT && isTransactionGroupListItemArray(data)) {
return emptyReports.length + flattenedItems.length;
}

return flattenedItems.length;
}, [data, type, flattenedItems, emptyReports]);

const {translate} = useLocalize();
const {isOffline} = useNetwork();
Expand Down Expand Up @@ -237,10 +259,6 @@ function SearchList({
if (shouldPreventLongPressRow || !isSmallScreenWidth || item?.isDisabled || item?.isDisabledCheckbox) {
return;
}
// disable long press for empty expense reports
if ('transactions' in item && item.transactions.length === 0 && !groupBy) {
return;
}
if (isMobileSelectionModeEnabled) {
onCheckboxPress(item, itemTransactions);
return;
Expand All @@ -249,7 +267,7 @@ function SearchList({
setLongPressedItemTransactions(itemTransactions);
setIsModalVisible(true);
},
[groupBy, route.key, shouldPreventLongPressRow, isSmallScreenWidth, isMobileSelectionModeEnabled, onCheckboxPress],
[route.key, shouldPreventLongPressRow, isSmallScreenWidth, isMobileSelectionModeEnabled, onCheckboxPress],
);

const turnOnSelectionMode = useCallback(() => {
Expand Down Expand Up @@ -373,7 +391,7 @@ function SearchList({

const tableHeaderVisible = (canSelectMultiple || !!SearchTableHeader) && (!groupBy || type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT);
const selectAllButtonVisible = canSelectMultiple && !SearchTableHeader;
const isSelectAllChecked = selectedItemsLength > 0 && selectedItemsLength === flattenedItemsWithoutPendingDelete.length;
const isSelectAllChecked = selectedItemsLength > 0 && selectedItemsLength === totalItems;

return (
<View style={[styles.flex1, !isKeyboardShown && safeAreaPaddingBottomStyle, containerStyle]}>
Expand All @@ -383,7 +401,7 @@ function SearchList({
<Checkbox
accessibilityLabel={translate('workspace.people.selectAll')}
isChecked={isSelectAllChecked}
isIndeterminate={selectedItemsLength > 0 && selectedItemsLength !== flattenedItemsWithoutPendingDelete.length}
isIndeterminate={selectedItemsLength > 0 && selectedItemsLength !== totalItems}
onPress={() => {
onAllCheckboxPress();
}}
Expand Down
Loading