Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import useTransactionViolations from '@hooks/useTransactionViolations';
import ControlSelection from '@libs/ControlSelection';
import canUseTouchScreen from '@libs/DeviceCapabilities/canUseTouchScreen';
import {hasFlexColumn} from '@libs/SearchUIUtils';
import {getTransactionPendingAction, isTransactionPendingDelete} from '@libs/TransactionUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -180,7 +181,7 @@ function MoneyRequestReportTransactionItem({
onArrowRightPress={() => onArrowRightPress?.(transaction.transactionID)}
isHover={hovered}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
shouldRemoveTotalColumnFlex
shouldRemoveTotalColumnFlex={hasFlexColumn(columns)}
/>
)}
</PressableWithFeedback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import {
isSortableColumnName,
} from '@libs/ReportUtils';
import type {SortableColumnName} from '@libs/ReportUtils';
import {compareValues, getColumnsToShow, getTableMinWidth, isTransactionAmountTooLong, isTransactionTaxAmountTooLong} from '@libs/SearchUIUtils';
import {compareValues, getColumnsToShow, getTableMinWidth, hasFlexColumn, isTransactionAmountTooLong, isTransactionTaxAmountTooLong} from '@libs/SearchUIUtils';
import {getPendingSubmitFollowUpAction} from '@libs/telemetry/submitFollowUpAction';
import {compareByRBR} from '@libs/TransactionPreviewUtils';
import {getTransactionPendingAction, isTransactionPendingDelete, shouldShowExpenseBreakdown} from '@libs/TransactionUtils';
Expand Down Expand Up @@ -714,7 +714,7 @@ function MoneyRequestReportTransactionList({
shouldShowSorting
sortBy={sortBy}
sortOrder={sortOrder}
shouldRemoveTotalColumnFlex
shouldRemoveTotalColumnFlex={hasFlexColumn(columnsToShow)}
columns={columnsToShow}
dateColumnSize={dateColumnSize}
amountColumnSize={amountColumnSize}
Expand Down
19 changes: 19 additions & 0 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5801,6 +5801,24 @@ function applySelectionToItem(
return {originalItem: item, itemWithSelection: {...item, isSelected, transactions}, isSelected};
}

const FLEX_COLUMNS = new Set<string>([
CONST.SEARCH.TABLE_COLUMNS.MERCHANT,
CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION,
CONST.SEARCH.TABLE_COLUMNS.CATEGORY,
CONST.SEARCH.TABLE_COLUMNS.TAG,
CONST.SEARCH.TABLE_COLUMNS.TAX_RATE,
Comment on lines +5804 to +5809
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include all flex-width columns in hasFlexColumn

hasFlexColumn() only treats MERCHANT, DESCRIPTION, CATEGORY, TAG, and TAX_RATE as flexible columns, but getReportTableColumnStyles() also renders other report-detail columns (for example CARD, WITHDRAWAL_ID, and EXCHANGE_RATE) with styles.flex1. In money request report views where one of those columns is the only flexible column and TOTAL is last, this helper returns false and keeps the total column flexible even though another flex column already exists, which regresses the intended width/alignment behavior this change is trying to normalize.

Useful? React with 👍 / 👎.

CONST.SEARCH.TABLE_COLUMNS.CARD,
CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE,
]);

/**
* Returns true when another flex column exists that can fill the remaining space,
* making it safe to remove flex from total columns.
*/
function hasFlexColumn(columns?: SearchColumnType[]): boolean {
return !!columns?.some((col) => FLEX_COLUMNS.has(col));
}

export {
getSearchBulkEditPolicyID,
getSuggestedSearches,
Expand Down Expand Up @@ -5880,6 +5898,7 @@ export {
FILTER_LABEL_MAP,
doesSearchItemMatchSort,
isPolicyEligibleForSpendOverTime,
hasFlexColumn,
};
export type {
SavedSearchMenuItem,
Expand Down
Loading