Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d8c1da2
feat: Add sticky group headers to Spend table by splitting groups int…
Krishna2323 May 29, 2026
bea81da
fix: Match GroupHeader styles with original TransactionGroupListItem …
Krishna2323 May 29, 2026
c93a49a
fix: Match GroupHeader arrow and separator styles with original Anima…
Krishna2323 May 29, 2026
e148a5b
fix: Move bottom padding inside animated content to avoid space when …
Krishna2323 May 29, 2026
248eecf
feat: Add sticky animated sub-header to GroupHeader for grouped searc…
Krishna2323 May 29, 2026
5980a0a
feat: Add sticky animated sub-header to GroupHeader with proper colum…
Krishna2323 May 29, 2026
1a393fa
fix: Correct border radius for last group item in split header/childr…
Krishna2323 May 30, 2026
34adab1
fix: Border radius, clickable sub-header, and deferred radius until a…
Krishna2323 May 30, 2026
05c4306
add sentryLabel
Krishna2323 May 30, 2026
97c9a10
fix: Sub-header selection bg, clickable toggle, sentry label, and bor…
Krishna2323 May 30, 2026
c2a32ec
fix: Disable hover effect on group header when expanded
Krishna2323 May 30, 2026
87cbc9b
fix: Preserve report row navigation and pass payment context to Group…
Krishna2323 May 30, 2026
d3d7d63
refactor: Merge header and sub-header into single pressable, fix onLo…
Krishna2323 May 30, 2026
912eaef
refactor: Merge header and sub-header into single pressable, restore …
Krishna2323 May 30, 2026
c7ca12d
fix: Remove subpixel gaps by returning null from collapsed children c…
Krishna2323 May 30, 2026
438e40b
Merge branch 'Expensify:main' into krishna/sticky-group-headers
Krishna2323 Jun 1, 2026
f69688b
fix: Remove header border-bottom when expanded on narrow screens, fix…
Krishna2323 Jun 1, 2026
a09c8e2
Scope sticky header changes to large screen width only, revert narrow…
Krishna2323 Jun 1, 2026
1b93219
fix: Align GroupHeader and GroupChildrenContainer behavior with main'…
Krishna2323 Jun 1, 2026
2b6d025
perf: Optimize sticky group headers by deferring expensive work to ex…
Krishna2323 Jun 1, 2026
bb880dc
fix: Polish sticky group header styling — border timing, selection hi…
Krishna2323 Jun 1, 2026
ad4792e
fix: Translate scroll indices and preserve original keys for split gr…
Krishna2323 Jun 2, 2026
44cf02a
fix: Make children container border selection-aware to stay visible w…
Krishna2323 Jun 2, 2026
9b8417e
Move sub-header border into sticky area and fix unused variable lint …
Krishna2323 Jun 2, 2026
903e5ed
Address PR review: extract shared animation hook, fix magic numbers, …
Krishna2323 Jun 2, 2026
335c5bf
add react import.
Krishna2323 Jun 2, 2026
1b37fe3
Merge branch 'Expensify:main' into krishna/sticky-group-headers
Krishna2323 Jun 2, 2026
30f174c
Merge branch 'Expensify:main' into krishna/sticky-group-headers
Krishna2323 Jun 3, 2026
01de445
Fix jelly scrolling by only applying sticky headers to expanded groups
Krishna2323 Jun 3, 2026
7b2a8e6
Merge branch 'main' into krishna/sticky-group-headers
Krishna2323 Jun 4, 2026
a901b0e
add missing useCallback dep, remove stale allReportMetadata usage, un…
Krishna2323 Jun 4, 2026
c74da45
Fix group header arrow icon size to 20px to match design
Krishna2323 Jun 4, 2026
455f534
refactor: reuse GroupChildrenContentProps and remove redundant condition
Krishna2323 Jun 5, 2026
188e027
fix: don't drill into search when clicking empty non-expense-report g…
Krishna2323 Jun 5, 2026
d0263ce
fix: use snapshot transactions for group selection and prevent drill-…
Krishna2323 Jun 5, 2026
8efed92
Merge branch 'Expensify:main' into krishna/sticky-group-headers
Krishna2323 Jun 6, 2026
26e8d7d
Merge branch 'Expensify:main' into krishna/sticky-group-headers
Krishna2323 Jun 8, 2026
c2bd800
Merge branch 'Expensify:main' into krishna/sticky-group-headers
Krishna2323 Jun 11, 2026
a648786
Address PR review comments: improve type safety and code quality
Krishna2323 Jun 11, 2026
284bad9
Simplify effectiveTransactions type narrowing in GroupHeader
Krishna2323 Jun 11, 2026
a98eb7a
remove as const.
Krishna2323 Jun 11, 2026
b2a8b73
Fix empty-report selection state using originalKey prop
Krishna2323 Jun 11, 2026
e3446df
Fix doubled border on sticky group headers with absolute-positioned c…
Krishna2323 Jun 11, 2026
05b6d29
Fix intermittent missing sub-header border with marginTop overlap
Krishna2323 Jun 11, 2026
c03de11
Add seatbelt entries for GroupChildrenContent and GroupHeader type as…
Krishna2323 Jun 11, 2026
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
2 changes: 2 additions & 0 deletions config/eslint/eslint.seatbelt.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@
"../../src/components/Search/SearchList/ListItem/ExpenseReportListItem.tsx" "@typescript-eslint/no-unsafe-type-assertion" 5
"../../src/components/Search/SearchList/ListItem/ExpenseReportListItemRow/ExpenseReportListItemRowWide.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/Search/SearchList/ListItem/MemberListItemHeader.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/components/Search/SearchList/ListItem/GroupChildrenContent.tsx" "@typescript-eslint/no-unsafe-type-assertion" 4
"../../src/components/Search/SearchList/ListItem/GroupHeader.tsx" "@typescript-eslint/no-unsafe-type-assertion" 3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These files parse Onyx snapshot data using the same snapshotData[key as keyof typeof snapshotData] as Transaction and value as TransactionViolations patterns already present in TransactionGroupListItem.tsx and TransactionGroupListExpanded.tsx.

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.

Should we add these exceptions here? Or should we disable lint for those lines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went with seatbelt since it's the same pattern used by TransactionGroupListItem.tsx and TransactionGroupListExpanded.tsx — the files this code was extracted from. Happy to switch to inline // eslint-disable-next-line if that's preferred for new files.

"../../src/components/Search/SearchList/ListItem/ReportListItemHeader.tsx" "@typescript-eslint/no-unsafe-type-assertion" 4
"../../src/components/Search/SearchList/ListItem/TaskListItem.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/Search/SearchList/ListItem/TransactionGroupListExpanded.tsx" "@typescript-eslint/no-unsafe-type-assertion" 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function BaseSearchList({
onViewableItemsChanged,
onLayout,
contentContainerStyle,
stickyHeaderIndices,
getItemType,
}: BaseSearchListProps) {
const renderItemWithoutKeyboardFocus = useCallback(
({item, index}: {item: SearchListItem; index: number}) => {
Expand All @@ -43,6 +45,8 @@ function BaseSearchList({
drawDistance={250}
contentContainerStyle={contentContainerStyle}
maintainVisibleContentPosition={{disabled: true}}
stickyHeaderIndices={stickyHeaderIndices}
getItemType={getItemType}
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Search/SearchList/BaseSearchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ function BaseSearchList({
selectedTransactions,
isAttendeesEnabledForMovingPolicy,
nonPersonalAndWorkspaceCards,
stickyHeaderIndices,
getItemType,
}: BaseSearchListProps) {
const hasKeyBeenPressed = useRef(false);
const isFocused = useIsFocused();
Expand Down Expand Up @@ -183,6 +185,8 @@ function BaseSearchList({
drawDistance={250}
contentContainerStyle={contentContainerStyle}
maintainVisibleContentPosition={{disabled: true}}
stickyHeaderIndices={stickyHeaderIndices}
getItemType={getItemType}
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Search/SearchList/BaseSearchList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type BaseSearchListProps = Pick<
| 'keyExtractor'
| 'showsVerticalScrollIndicator'
| 'onLayout'
| 'stickyHeaderIndices'
> & {
/** The data to display in the list */
data: SearchListItem[];
Expand Down Expand Up @@ -50,6 +51,9 @@ type BaseSearchListProps = Pick<

/** Non-personal and workspace cards for triggering re-render via extraData */
nonPersonalAndWorkspaceCards?: CardList;

/** Function to determine item type for FlashList recycling */
getItemType?: (item: SearchListItem, index: number) => string | number | undefined;
};

export default BaseSearchListProps;
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import {View} from 'react-native';
import Animated from 'react-native-reanimated';
import useExpandCollapseAnimation from '@hooks/useExpandCollapseAnimation';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import GroupChildrenContent from './GroupChildrenContent';
import type {GroupChildrenContentProps} from './types';

type GroupChildrenContainerProps = GroupChildrenContentProps & {
isLastItem?: boolean;
isSelected?: boolean;
};

function GroupChildrenContainer({
item,
isExpanded,
groupBy,
searchType,
columns,
canSelectMultiple,
onSelectRow,
onCheckboxPress,
onLongPressRow,
nonPersonalAndWorkspaceCards,
onUndelete,
isLastItem,
isSelected,
newTransactionID,
bankAccountList,
cardFeeds,
conciergeReportID,
}: GroupChildrenContainerProps) {
const theme = useTheme();
const styles = useThemeStyles();
const {isRendered, animatedStyle, onLayout} = useExpandCollapseAnimation(isExpanded);

if (!isExpanded && !isRendered) {
return null;
}

return (
<View style={[styles.mh5, {backgroundColor: isSelected ? theme.activeComponentBG : theme.highlightBG}, isLastItem && [styles.tableBottomRadius, styles.overflowHidden]]}>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Filing this against #92067, this never had an isFirstItem concept, so the first child row always got the same border/spacing as later rows, and the grouped-view header padding didn't match. Fixed in #99586.

<Animated.View style={animatedStyle}>
<Animated.View
style={[styles.stickToTop, styles.pb1]}
onLayout={onLayout}
>
<GroupChildrenContent
item={item}
isExpanded={isExpanded}
groupBy={groupBy}
searchType={searchType}
columns={columns}
canSelectMultiple={canSelectMultiple}
onSelectRow={onSelectRow}
onCheckboxPress={onCheckboxPress}
onLongPressRow={onLongPressRow}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
onUndelete={onUndelete}
newTransactionID={newTransactionID}
bankAccountList={bankAccountList}
cardFeeds={cardFeeds}
conciergeReportID={conciergeReportID}
/>
</Animated.View>
</Animated.View>
</View>
);
}

export default GroupChildrenContainer;
227 changes: 227 additions & 0 deletions src/components/Search/SearchList/ListItem/GroupChildrenContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
import {useIsFocused} from '@react-navigation/native';
import React, {useEffect, useMemo, useState} from 'react';
import {useSearchSelectionContext} from '@components/Search/SearchContext';
import useActionLoadingReportIDs from '@hooks/useActionLoadingReportIDs';
import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import {search} from '@libs/actions/Search';
import {getSections} from '@libs/SearchUIUtils';
import {mergeProhibitedViolations, shouldShowViolation} from '@libs/TransactionUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Transaction, TransactionViolation, TransactionViolations} from '@src/types/onyx';
import TransactionGroupListExpandedItem from './TransactionGroupListExpanded';
import type {GroupChildrenContentProps, TransactionListItemType} from './types';

function GroupChildrenContent({
item,
isExpanded,
groupBy,
searchType,
columns,
canSelectMultiple,
onSelectRow,
onCheckboxPress,
onLongPressRow,
nonPersonalAndWorkspaceCards,
onUndelete,
newTransactionID,
bankAccountList,
cardFeeds,
conciergeReportID,
}: GroupChildrenContentProps) {
const {translate, formatPhoneNumber} = useLocalize();
const {selectedTransactions} = useSearchSelectionContext();
const currentUserDetails = useCurrentUserPersonalDetails();
const isScreenFocused = useIsFocused();
const {convertToDisplayString} = useCurrencyListActions();
const {isOffline} = useNetwork();

const groupItem = item;
const isExpenseReportType = searchType === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT;

const [transactionsSnapshot] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${groupItem.transactionsQueryJSON?.hash}`);
const [transactionsVisibleLimit, setTransactionsVisibleLimit] = useState<number>(CONST.TRANSACTION.RESULTS_PAGE_SIZE);
const isActionLoadingSet = useActionLoadingReportIDs();
const snapshotData = transactionsSnapshot?.data;

const selectedTransactionIDsSet = useMemo(() => new Set(Object.keys(selectedTransactions)), [selectedTransactions]);

const transactions: TransactionListItemType[] = useMemo(() => {
if (isExpenseReportType) {
return groupItem.transactions;
}
if (!snapshotData) {
return [];
}
const [sectionData] = getSections({

Check failure on line 60 in src/components/Search/SearchList/ListItem/GroupChildrenContent.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe type assertion: type '[TransactionListItemType[], number, boolean]' is more narrow than the original type
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
data: snapshotData,
currentAccountID: currentUserDetails.accountID,
currentUserEmail: currentUserDetails.email ?? '',
translate,
formatPhoneNumber,
bankAccountList,
isActionLoadingSet,
cardFeeds,
conciergeReportID,
convertToDisplayString,
}) as [TransactionListItemType[], number, boolean];
return sectionData.map((transactionItem) => ({
...transactionItem,
isSelected: selectedTransactionIDsSet.has(transactionItem.transactionID),
}));
}, [
isExpenseReportType,
groupItem.transactions,
snapshotData,
currentUserDetails.accountID,
currentUserDetails.email,
translate,
formatPhoneNumber,
bankAccountList,
isActionLoadingSet,
cardFeeds,
conciergeReportID,
convertToDisplayString,
selectedTransactionIDsSet,
]);

const isEmpty = transactions.length === 0;
const shouldDisplayEmptyView = isEmpty && isExpenseReportType;

const refreshTransactions = () => {
if (!groupItem.transactionsQueryJSON) {
return;
}
search({
queryJSON: groupItem.transactionsQueryJSON,
searchKey: undefined,
offset: 0,
shouldCalculateTotals: false,
isLoading: !!transactionsSnapshot?.search?.isLoading,
isOffline,
});
};

const searchTransactions = (pageSize = 0) => {
if (!groupItem.transactionsQueryJSON) {
return;
}
search({
queryJSON: groupItem.transactionsQueryJSON,
searchKey: undefined,
offset: (transactionsSnapshot?.search?.offset ?? 0) + pageSize,
shouldCalculateTotals: false,
isLoading: !!transactionsSnapshot?.search?.isLoading,
isOffline,
});
};

useEffect(() => {
if (!newTransactionID || !isExpanded) {
return;
}
refreshTransactions();
// Only refresh when a new transaction is created in this group — refreshTransactions is excluded to avoid infinite loops
// eslint-disable-next-line react-hooks/exhaustive-deps
Comment thread
Krishna2323 marked this conversation as resolved.
Resolved
}, [newTransactionID, isExpanded]);

useEffect(() => {
if (!isExpanded || isExpenseReportType) {
return;
}
refreshTransactions();
Comment thread
Krishna2323 marked this conversation as resolved.
Resolved
// Only fetch on expand — refreshTransactions and isExpenseReportType are excluded to prevent re-fetching on every render
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isExpanded]);

const wasScreenFocusedRef = React.useRef(isScreenFocused);
useEffect(() => {
const didReturnToScreen = wasScreenFocusedRef.current === false && isScreenFocused === true;
wasScreenFocusedRef.current = isScreenFocused;
if (!didReturnToScreen || !isExpanded || isExpenseReportType) {
return;
Comment thread
Krishna2323 marked this conversation as resolved.
Resolved
}
refreshTransactions();
// Only refresh when returning to this screen while expanded — other deps excluded to avoid redundant fetches
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isScreenFocused]);

const filteredViolations: Record<string, TransactionViolation[]> = useMemo(() => {
if (!snapshotData) {
return {};
}

const groupViolations: Record<string, TransactionViolations | undefined> = {};
for (const [key, value] of Object.entries(snapshotData)) {
if (key.startsWith(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS)) {
groupViolations[key] = value as TransactionViolations;

Check failure on line 162 in src/components/Search/SearchList/ListItem/GroupChildrenContent.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe type assertion: type 'TransactionViolations' is more narrow than the original type
}
}

const result: Record<string, TransactionViolation[]> = {};
for (const key of Object.keys(snapshotData)) {
if (!key.startsWith(ONYXKEYS.COLLECTION.TRANSACTION)) {
continue;
}
const snapshotTransaction = snapshotData[key as keyof typeof snapshotData] as Transaction;

Check failure on line 171 in src/components/Search/SearchList/ListItem/GroupChildrenContent.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe type assertion: type '"personalDetailsList" | `policy_${string}` | `report_${string}` | `reportNameValuePairs_${string}` | `reportMetadata_${string}` | `reportActions_${string}` | `transactions_${string}` | `transactionViolations_${string}` | `group_${string}`' is more narrow than the original type

Check failure on line 171 in src/components/Search/SearchList/ListItem/GroupChildrenContent.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe type assertion: type '{ amount: number; accountant?: Accountant | undefined; convertedAmount?: number | undefined; currencyConversionRate?: string | undefined; taxAmount?: number | undefined; ... 60 more ...; transactionType?: string | undefined; } & OfflineFeedback<...>' is more narrow than the original type
if (!snapshotTransaction || typeof snapshotTransaction !== 'object' || !('transactionID' in snapshotTransaction) || !('reportID' in snapshotTransaction)) {
continue;
}

const report = snapshotData[`${ONYXKEYS.COLLECTION.REPORT}${snapshotTransaction.reportID}`];
const policy = snapshotData[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];

if (report && policy) {
const transactionViolations = groupViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${snapshotTransaction.transactionID}`];
if (transactionViolations) {
const merged = mergeProhibitedViolations(
transactionViolations.filter((violation) => shouldShowViolation(report, policy, violation.name, currentUserDetails?.email ?? '', true, snapshotTransaction)),
);
if (merged.length > 0) {
result[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${snapshotTransaction.transactionID}`] = merged;
}
}
}
}
return result;
}, [snapshotData, currentUserDetails.email]);

const onExpandedRowLongPress = (transaction: TransactionListItemType) => {
onLongPressRow?.(transaction);
};

return (
<TransactionGroupListExpandedItem
showTooltip
canSelectMultiple={canSelectMultiple}
onSelectionButtonPress={onCheckboxPress}
onSelectRow={onSelectRow}
columns={columns}
groupBy={groupBy}
accountID={currentUserDetails.accountID}
isOffline={isOffline}
violations={filteredViolations}
transactions={transactions}
transactionsVisibleLimit={transactionsVisibleLimit}
setTransactionsVisibleLimit={setTransactionsVisibleLimit}
isEmpty={isEmpty}
shouldDisplayEmptyView={shouldDisplayEmptyView}
isExpenseReportType={isExpenseReportType}
transactionsSnapshot={transactionsSnapshot}
transactionsQueryJSON={groupItem.transactionsQueryJSON}
searchTransactions={searchTransactions}
isInSingleTransactionReport={groupItem.transactions.length === 1}
onLongPress={onExpandedRowLongPress}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
onUndelete={onUndelete}
hideSearchTableHeader
/>
);
}

export default GroupChildrenContent;
Loading
Loading