Skip to content

Commit ef9ee8b

Browse files
authored
Merge pull request Expensify#89859 from Krishna2323/krishna2323/issue/89838
[CP Staging] Fix Total column not aligned to right edge when no merchant column is visible
2 parents ca84a2c + 45ca157 commit ef9ee8b

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
1616
import useTransactionViolations from '@hooks/useTransactionViolations';
1717
import ControlSelection from '@libs/ControlSelection';
1818
import canUseTouchScreen from '@libs/DeviceCapabilities/canUseTouchScreen';
19+
import {hasFlexColumn} from '@libs/SearchUIUtils';
1920
import {getTransactionPendingAction, isTransactionPendingDelete} from '@libs/TransactionUtils';
2021
import variables from '@styles/variables';
2122
import CONST from '@src/CONST';
@@ -180,7 +181,7 @@ function MoneyRequestReportTransactionItem({
180181
onArrowRightPress={() => onArrowRightPress?.(transaction.transactionID)}
181182
isHover={hovered}
182183
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
183-
shouldRemoveTotalColumnFlex
184+
shouldRemoveTotalColumnFlex={hasFlexColumn(columns)}
184185
/>
185186
)}
186187
</PressableWithFeedback>

src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import {
6060
isSortableColumnName,
6161
} from '@libs/ReportUtils';
6262
import type {SortableColumnName} from '@libs/ReportUtils';
63-
import {compareValues, getColumnsToShow, getTableMinWidth, isTransactionAmountTooLong, isTransactionTaxAmountTooLong} from '@libs/SearchUIUtils';
63+
import {compareValues, getColumnsToShow, getTableMinWidth, hasFlexColumn, isTransactionAmountTooLong, isTransactionTaxAmountTooLong} from '@libs/SearchUIUtils';
6464
import {getPendingSubmitFollowUpAction} from '@libs/telemetry/submitFollowUpAction';
6565
import {compareByRBR} from '@libs/TransactionPreviewUtils';
6666
import {getTransactionPendingAction, isTransactionPendingDelete, shouldShowExpenseBreakdown} from '@libs/TransactionUtils';
@@ -714,7 +714,7 @@ function MoneyRequestReportTransactionList({
714714
shouldShowSorting
715715
sortBy={sortBy}
716716
sortOrder={sortOrder}
717-
shouldRemoveTotalColumnFlex
717+
shouldRemoveTotalColumnFlex={hasFlexColumn(columnsToShow)}
718718
columns={columnsToShow}
719719
dateColumnSize={dateColumnSize}
720720
amountColumnSize={amountColumnSize}

src/libs/SearchUIUtils.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5801,6 +5801,24 @@ function applySelectionToItem(
58015801
return {originalItem: item, itemWithSelection: {...item, isSelected, transactions}, isSelected};
58025802
}
58035803

5804+
const FLEX_COLUMNS = new Set<string>([
5805+
CONST.SEARCH.TABLE_COLUMNS.MERCHANT,
5806+
CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION,
5807+
CONST.SEARCH.TABLE_COLUMNS.CATEGORY,
5808+
CONST.SEARCH.TABLE_COLUMNS.TAG,
5809+
CONST.SEARCH.TABLE_COLUMNS.TAX_RATE,
5810+
CONST.SEARCH.TABLE_COLUMNS.CARD,
5811+
CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE,
5812+
]);
5813+
5814+
/**
5815+
* Returns true when another flex column exists that can fill the remaining space,
5816+
* making it safe to remove flex from total columns.
5817+
*/
5818+
function hasFlexColumn(columns?: SearchColumnType[]): boolean {
5819+
return !!columns?.some((col) => FLEX_COLUMNS.has(col));
5820+
}
5821+
58045822
export {
58055823
getSearchBulkEditPolicyID,
58065824
getSuggestedSearches,
@@ -5880,6 +5898,7 @@ export {
58805898
FILTER_LABEL_MAP,
58815899
doesSearchItemMatchSort,
58825900
isPolicyEligibleForSpendOverTime,
5901+
hasFlexColumn,
58835902
};
58845903
export type {
58855904
SavedSearchMenuItem,

0 commit comments

Comments
 (0)