Skip to content

Commit d3c5de1

Browse files
authored
Merge pull request #42932 from Expensify/cmartins-fixReportTotalAndAlignment
Fix report total and alignment
2 parents e4b9324 + bcfa1ef commit d3c5de1

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

src/components/SelectionList/Search/ReportListItem.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function ReportListItem<TItem extends ListItem>({
5252
const totalCell = (
5353
<TextWithTooltip
5454
shouldShowTooltip={showTooltip}
55-
text={CurrencyUtils.convertToDisplayString(reportItem?.total, reportItem?.currency)}
55+
text={CurrencyUtils.convertToDisplayString((reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1) * (reportItem?.total ?? 0), reportItem?.currency)}
5656
style={[styles.optionDisplayName, styles.textNewKansasNormal, styles.pre, styles.justifyContentCenter, isLargeScreenWidth ? undefined : styles.textAlignRight]}
5757
/>
5858
);
@@ -130,7 +130,7 @@ function ReportListItem<TItem extends ListItem>({
130130
onButtonPress={handleOnButtonPress}
131131
/>
132132
)}
133-
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
133+
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap3]}>
134134
<View style={[styles.flexRow, styles.flex1, styles.alignItemsCenter, styles.justifyContentBetween]}>
135135
<View style={[styles.flexRow, styles.alignItemsCenter, styles.flex2]}>
136136
<View style={[styles.flexShrink1]}>
@@ -140,9 +140,12 @@ function ReportListItem<TItem extends ListItem>({
140140
</View>
141141
<View style={[styles.flexRow, styles.flex1, styles.justifyContentEnd]}>{totalCell}</View>
142142
</View>
143-
{/** styles.reportListItemActionButtonMargin added here to move the action button by the type column distance */}
144143
{isLargeScreenWidth && (
145-
<View style={[StyleUtils.getSearchTableColumnStyles(CONST.SEARCH_TABLE_COLUMNS.ACTION), styles.reportListItemActionButtonMargin]}>{actionCell}</View>
144+
<>
145+
{/** We add an empty view with type style to align the total with the table header */}
146+
<View style={StyleUtils.getSearchTableColumnStyles(CONST.SEARCH_TABLE_COLUMNS.TYPE)} />
147+
<View style={StyleUtils.getSearchTableColumnStyles(CONST.SEARCH_TABLE_COLUMNS.ACTION)}>{actionCell}</View>
148+
</>
146149
)}
147150
</View>
148151
<View style={[styles.mt3, styles.reportListItemSeparator]} />
@@ -156,6 +159,7 @@ function ReportListItem<TItem extends ListItem>({
156159
showItemHeaderOnNarrowLayout={false}
157160
containerStyle={styles.mt3}
158161
isHovered={hovered}
162+
isChildListItem
159163
/>
160164
))}
161165
</View>

src/components/SelectionList/Search/TransactionListItemRow.tsx

+18-3
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,18 @@ type ActionCellProps = {
4141
onButtonPress: () => void;
4242
} & CellProps;
4343

44+
type TotalCellProps = {
45+
isChildListItem: boolean;
46+
} & TransactionCellProps;
47+
4448
type TransactionListItemRowProps = {
4549
item: TransactionListItemType;
4650
showTooltip: boolean;
4751
onButtonPress: () => void;
4852
showItemHeaderOnNarrowLayout?: boolean;
4953
containerStyle?: StyleProp<ViewStyle>;
5054
isHovered?: boolean;
55+
isChildListItem?: boolean;
5156
};
5257

5358
const getTypeIcon = (type?: SearchTransactionType) => {
@@ -112,15 +117,15 @@ function MerchantCell({transactionItem, showTooltip}: TransactionCellProps) {
112117
);
113118
}
114119

115-
function TotalCell({showTooltip, isLargeScreenWidth, transactionItem}: TransactionCellProps) {
120+
function TotalCell({showTooltip, isLargeScreenWidth, transactionItem, isChildListItem}: TotalCellProps) {
116121
const styles = useThemeStyles();
117122
const currency = TransactionUtils.getCurrency(transactionItem);
118123

119124
return (
120125
<TextWithTooltip
121126
shouldShowTooltip={showTooltip}
122127
text={CurrencyUtils.convertToDisplayString(transactionItem.formattedTotal, currency)}
123-
style={[styles.optionDisplayName, styles.textNewKansasNormal, styles.pre, styles.justifyContentCenter, isLargeScreenWidth ? undefined : styles.textAlignRight]}
128+
style={[styles.optionDisplayName, styles.justifyContentCenter, isLargeScreenWidth ? undefined : styles.textAlignRight, isChildListItem ? styles.label : undefined]}
124129
/>
125130
);
126131
}
@@ -204,7 +209,15 @@ function TaxCell({transactionItem, showTooltip}: TransactionCellProps) {
204209
);
205210
}
206211

207-
function TransactionListItemRow({item, showTooltip, onButtonPress, showItemHeaderOnNarrowLayout = true, containerStyle, isHovered = false}: TransactionListItemRowProps) {
212+
function TransactionListItemRow({
213+
item,
214+
showTooltip,
215+
onButtonPress,
216+
showItemHeaderOnNarrowLayout = true,
217+
containerStyle,
218+
isHovered = false,
219+
isChildListItem = false,
220+
}: TransactionListItemRowProps) {
208221
const styles = useThemeStyles();
209222
const {translate} = useLocalize();
210223
const {isLargeScreenWidth} = useWindowDimensions();
@@ -255,6 +268,7 @@ function TransactionListItemRow({item, showTooltip, onButtonPress, showItemHeade
255268
showTooltip={showTooltip}
256269
transactionItem={item}
257270
isLargeScreenWidth={isLargeScreenWidth}
271+
isChildListItem={isChildListItem}
258272
/>
259273
<View style={[styles.flexRow, styles.gap1, styles.justifyContentCenter]}>
260274
<TypeCell
@@ -344,6 +358,7 @@ function TransactionListItemRow({item, showTooltip, onButtonPress, showItemHeade
344358
showTooltip={showTooltip}
345359
transactionItem={item}
346360
isLargeScreenWidth={isLargeScreenWidth}
361+
isChildListItem={isChildListItem}
347362
/>
348363
</View>
349364
<View style={[StyleUtils.getSearchTableColumnStyles(CONST.SEARCH_TABLE_COLUMNS.TYPE)]}>

src/languages/es.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ export default {
325325
action: 'Acción',
326326
expenses: 'Gastos',
327327
tax: 'Impuesto',
328-
shared: 'Compartido',
328+
shared: 'Compartidos',
329329
drafts: 'Borradores',
330-
finished: 'Finalizado',
330+
finished: 'Finalizados',
331331
},
332332
connectionComplete: {
333333
title: 'Conexión Completa',

src/styles/index.ts

-4
Original file line numberDiff line numberDiff line change
@@ -4950,10 +4950,6 @@ const styles = (theme: ThemeColors) =>
49504950
fontSize: variables.fontSizeNormal,
49514951
fontWeight: FontUtils.fontWeight.bold,
49524952
},
4953-
4954-
reportListItemActionButtonMargin: {
4955-
marginLeft: variables.searchTypeColumnWidth,
4956-
},
49574953
} satisfies Styles);
49584954

49594955
type ThemeStyles = ReturnType<typeof styles>;

src/types/onyx/SearchResults.ts

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ type SearchReport = {
6060
/** The report currency */
6161
currency?: string;
6262

63+
/** The report type */
64+
type?: string;
65+
6366
/** The action that can be performed for the report */
6467
action?: string;
6568
};

0 commit comments

Comments
 (0)