Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ function TransactionListItem<TItem extends ListItem>({
exportedColumnSize={exportedColumnSize}
amountColumnSize={amountColumnSize}
taxAmountColumnSize={taxAmountColumnSize}
isActionColumnWide={transactionItem.isActionColumnWide}
shouldShowCheckbox={!!canSelectMultiple}
checkboxSentryLabel={CONST.SENTRY_LABEL.SEARCH.TRANSACTION_LIST_ITEM_CHECKBOX}
style={[styles.p3, styles.pv2, shouldUseNarrowLayout ? styles.pt2 : isLargeScreenWidth && styles.noBorderRadius]}
Expand Down
5 changes: 5 additions & 0 deletions src/components/Search/SearchList/ListItem/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ type TransactionListItemType = ListItem &

isTaxAmountColumnWide: boolean;

/** Whether the action column should use its wider variant.
* This is true if at least one transaction in the dataset is deleted.
*/
isActionColumnWide: boolean;

/** Key used internally by React */
keyForList: string;

Expand Down
6 changes: 5 additions & 1 deletion src/components/Search/SearchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ type SearchListProps = Pick<FlashListProps<SearchListItem>, 'onScroll' | 'conten
/** Whether all transactions have been loaded from snapshots in group-by views */
hasLoadedAllTransactions?: boolean;

/** Whether the action column should use its wider variant (e.g. when there is at least one deleted transaction) */
isActionColumnWide?: boolean;

/** Reference to the outer element */
ref?: ForwardedRef<SearchListHandle>;
};
Expand Down Expand Up @@ -218,6 +221,7 @@ function SearchList({
nonPersonalAndWorkspaceCards,
selectedTransactions,
hasLoadedAllTransactions,
isActionColumnWide,
ref,
}: SearchListProps) {
const styles = useThemeStyles();
Expand Down Expand Up @@ -332,7 +336,7 @@ function SearchList({
}, [data, groupBy, newTransactions]);

const {windowWidth} = useWindowDimensions();
const minTableWidth = getTableMinWidth(columns, queryJSON.type);
const minTableWidth = getTableMinWidth(columns, queryJSON.type, isActionColumnWide);
const shouldScrollHorizontally = !!SearchTableHeader && minTableWidth > windowWidth;

const horizontalScrollViewRef = useRef<RNScrollView>(null);
Expand Down
6 changes: 5 additions & 1 deletion src/components/Search/SearchTableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ type SearchTableHeaderProps = {

/** True when we are inside an expense report view, false if we're in the Reports page. */
isExpenseReportView?: boolean;

/** True when the action column should render in its wider variant (e.g. tasks, deleted expenses). */
isActionColumnWide?: boolean;
};

function SearchTableHeader({
Expand All @@ -468,6 +471,7 @@ function SearchTableHeader({
isTaxAmountColumnWide,
groupBy,
isExpenseReportView,
isActionColumnWide,
}: SearchTableHeaderProps) {
const styles = useThemeStyles();
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
Expand Down Expand Up @@ -540,7 +544,7 @@ function SearchTableHeader({
sortBy={sortBy}
sortOrder={sortOrder}
shouldRemoveTotalColumnFlex={!!groupBy !== !!isExpenseReportView}
isActionColumnWide={type === CONST.SEARCH.DATA_TYPES.TASK}
isActionColumnWide={isActionColumnWide ?? type === CONST.SEARCH.DATA_TYPES.TASK}
// Don't butt up against the 'select all' checkbox if present
containerStyles={canSelectMultiple && [styles.pl3]}
onSortPress={(columnName, order) => {
Expand Down
5 changes: 5 additions & 0 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
getSortedSections,
getValidGroupBy,
getWideAmountIndicators,
hasDeletedTransactionInData,
isGroupedItemArray,
isReportActionListItemType,
isSearchDataLoaded,
Expand Down Expand Up @@ -1167,7 +1168,7 @@

requestAnimationFrame(() => Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID, backTo})));
},
[

Check warning on line 1171 in src/components/Search/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useCallback has an unnecessary dependency: 'currentSearchKey'. Either exclude it or remove the dependency array

Check warning on line 1171 in src/components/Search/index.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has an unnecessary dependency: 'currentSearchKey'. Either exclude it or remove the dependency array
isMobileSelectionModeEnabled,
markReportIDAsExpense,
toggleTransaction,
Expand Down Expand Up @@ -1488,6 +1489,8 @@
[searchResults?.data],
);

const hasDeletedTransaction = useMemo(() => (searchResults?.data ? hasDeletedTransactionInData(searchResults.data) : false), [searchResults?.data]);

const onSortPress = useCallback(
(column: SearchColumnType, order: SortOrder) => {
clearSelectedTransactions();
Expand Down Expand Up @@ -1652,6 +1655,7 @@
shouldShowSorting
groupBy={validGroupBy}
isExpenseReportView={isExpenseReportType}
isActionColumnWide={isTask || hasDeletedTransaction}
/>
</View>
)
Expand Down Expand Up @@ -1683,6 +1687,7 @@
newTransactions={newTransactions}
hasLoadedAllTransactions={hasLoadedAllTransactions}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
isActionColumnWide={isTask || hasDeletedTransaction}
/>
</Animated.View>
</SearchScopeProvider>
Expand Down
4 changes: 3 additions & 1 deletion src/components/TransactionItemRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ type TransactionItemRowProps = {
checkboxSentryLabel?: string;
isLargeScreenWidth?: boolean;
nonPersonalAndWorkspaceCards?: CardList;
isActionColumnWide?: boolean;
};

const EMPTY_ACTIVE_STYLE: StyleProp<ViewStyle> = [];
Expand Down Expand Up @@ -198,6 +199,7 @@ function TransactionItemRow({
checkboxSentryLabel,
nonPersonalAndWorkspaceCards = {},
isLargeScreenWidth: isLargeScreenWidthProp,
isActionColumnWide: isActionColumnWideProp,
}: TransactionItemRowProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -412,7 +414,7 @@ function TransactionItemRow({
return (
<View
key={column}
style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.ACTION)]}
style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.ACTION, {isActionColumnWide: isActionColumnWideProp ?? isDeletedTransaction})]}
>
{!!transactionItem.action && (
<ActionCell
Expand Down
37 changes: 35 additions & 2 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,28 @@
};
}

function hasDeletedTransactionInData(data: TransactionListItemType[] | TransactionGroupListItemType[] | TaskListItemType[] | OnyxTypes.SearchResults['data']): boolean {
if (Array.isArray(data)) {
return data.some((item) => {
if (isTransactionGroupListItemType(item)) {
return item.transactions.some((transaction) => transaction.reportID === CONST.REPORT.TRASH_REPORT_ID);
}
if (isTransactionListItemType(item)) {
return item.reportID === CONST.REPORT.TRASH_REPORT_ID;
}
return false;
});
}

return Object.keys(data).some((key) => {
if (isTransactionEntry(key)) {
const item = data[key];
return item?.reportID === CONST.REPORT.TRASH_REPORT_ID;
}
return false;
});
}

type ShouldShowYearResult = {
shouldShowYearCreated: boolean;
shouldShowYearSubmitted: boolean;
Expand Down Expand Up @@ -1729,6 +1751,7 @@
shouldShowYearExportedReport: boolean;
shouldShowAmountInWideColumn: boolean;
shouldShowTaxAmountInWideColumn: boolean;
hasDeletedTransaction: boolean;
currentYear: number;
};

Expand All @@ -1754,6 +1777,7 @@
shouldShowYearExportedReport: false,
shouldShowAmountInWideColumn: false,
shouldShowTaxAmountInWideColumn: false,
hasDeletedTransaction: false,
currentYear: new Date().getFullYear(),
};
}
Expand Down Expand Up @@ -1837,6 +1861,9 @@
if (!ctx.shouldShowTaxAmountInWideColumn) {
ctx.shouldShowTaxAmountInWideColumn = isTransactionTaxAmountTooLong(transaction);
}
if (!ctx.hasDeletedTransaction) {
ctx.hasDeletedTransaction = transaction.reportID === CONST.REPORT.TRASH_REPORT_ID;
}

if (!ctx.shouldShowYearCreated) {
const transactionCreated = getTransactionCreatedDate(transaction);
Expand Down Expand Up @@ -2038,6 +2065,7 @@
shouldShowYearExported,
shouldShowAmountInWideColumn,
shouldShowTaxAmountInWideColumn,
hasDeletedTransaction,
} = classifyAndPreprocess(data);

const personalDetailsMap = new Map(Object.entries(data.personalDetailsList ?? {}));
Expand Down Expand Up @@ -2122,6 +2150,7 @@
shouldShowYearExported,
isAmountColumnWide: shouldShowAmountInWideColumn,
isTaxAmountColumnWide: shouldShowTaxAmountInWideColumn,
isActionColumnWide: hasDeletedTransaction,
violations: transactionViolations,
category: isIOUReport ? '' : transactionItem?.category,
errors: undefined,
Expand Down Expand Up @@ -2623,6 +2652,7 @@
shouldShowYearExportedReport,
shouldShowAmountInWideColumn,
shouldShowTaxAmountInWideColumn,
hasDeletedTransaction,
} = classifyAndPreprocess(data);

const currentQueryJSON = queryJSON ?? getCurrentSearchQueryJSON();
Expand Down Expand Up @@ -2721,6 +2751,7 @@
nonReimbursableSpend,
reimbursableSpend,
isAmountColumnWide: shouldShowAmountInWideColumn,
isActionColumnWide: hasDeletedTransaction,

Check failure on line 2754 in src/libs/SearchUIUtils.ts

View workflow job for this annotation

GitHub Actions / typecheck

Object literal may only specify known properties, but 'isActionColumnWide' does not exist in type 'TransactionReportGroupListItemType'. Did you mean to write 'isAmountColumnWide'?
isAllScanning: false,
...avatarProps,
};
Expand Down Expand Up @@ -2781,6 +2812,7 @@
violations: transactionViolations,
isAmountColumnWide: shouldShowAmountInWideColumn,
isTaxAmountColumnWide: shouldShowTaxAmountInWideColumn,
isActionColumnWide: hasDeletedTransaction,
category: isIOUReport ? '' : transactionItem?.category,
errors: undefined,
};
Expand Down Expand Up @@ -5579,7 +5611,7 @@
return transaction as OnyxTypes.Transaction;
}

function getTableMinWidth(columns: SearchColumnType[], type?: SearchDataTypes) {
function getTableMinWidth(columns: SearchColumnType[], type?: SearchDataTypes, isActionColumnWide?: boolean) {
// Starts at 24px to account for the checkbox width
let minWidth = 24;

Expand All @@ -5593,7 +5625,7 @@
} else if (column === CONST.SEARCH.TABLE_COLUMNS.STATUS) {
minWidth += 80;
} else if (column === CONST.SEARCH.TABLE_COLUMNS.ACTION) {
minWidth += type === CONST.SEARCH.DATA_TYPES.TASK ? 80 : 68;
minWidth += (isActionColumnWide ?? type === CONST.SEARCH.DATA_TYPES.TASK) ? 80 : 68;
} else if (column === CONST.SEARCH.TABLE_COLUMNS.DATE) {
minWidth += 48;
} else if (
Expand Down Expand Up @@ -5826,6 +5858,7 @@
getCurrencyOptions,
getFeedOptions,
getWideAmountIndicators,
hasDeletedTransactionInData,
isTransactionAmountTooLong,
isTransactionTaxAmountTooLong,
getDatePresets,
Expand Down
Loading