Skip to content

Commit ad88724

Browse files
authored
Merge pull request Expensify#62936 from software-mansion-labs/bugfix/kuba_nowakowski/make_chatbubbgle_gray_when_readed
Fix logic of single transaction report
2 parents 6a29bdf + b1af887 commit ad88724

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/components/SelectionList/Search/ReportListItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ function ReportListItem<TItem extends ListItem>({
155155
isParentHovered={hovered}
156156
columnWrapperStyles={[styles.ph3, styles.pv1half]}
157157
isReportItemChild
158+
isInSingleTransactionReport={reportItem.transactions.length === 1}
158159
/>
159160
</View>
160161
))

src/components/TransactionItemRow/DataCells/ChatBubbleCell.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import type Transaction from '@src/types/onyx/Transaction';
1919
const isReportUnread = ({lastReadTime = '', lastVisibleActionCreated = '', lastMentionedTime = ''}: Report): boolean =>
2020
lastReadTime < lastVisibleActionCreated || lastReadTime < (lastMentionedTime ?? '');
2121

22-
function ChatBubbleCell({transaction, containerStyles}: {transaction: Transaction; containerStyles?: ViewStyle[]}) {
22+
function ChatBubbleCell({transaction, containerStyles, isInSingleTransactionReport}: {transaction: Transaction; containerStyles?: ViewStyle[]; isInSingleTransactionReport?: boolean}) {
2323
const theme = useTheme();
2424
const styles = useThemeStyles();
2525
const {shouldUseNarrowLayout} = useResponsiveLayout();
@@ -28,10 +28,16 @@ function ChatBubbleCell({transaction, containerStyles}: {transaction: Transactio
2828
canBeMissing: true,
2929
});
3030

31-
const [transactionReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportAction?.childReportID}`, {
31+
const [childReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportAction?.childReportID}`, {
3232
canBeMissing: true,
3333
});
3434

35+
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transaction.reportID}`, {
36+
canBeMissing: false,
37+
});
38+
39+
const transactionReport = isInSingleTransactionReport ? parentReport : childReport;
40+
3541
const threadMessages = useMemo(
3642
() => ({
3743
count: (iouReportAction && iouReportAction?.childVisibleActionCount) ?? 0,

src/components/TransactionItemRow/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ type TransactionItemRowProps = {
9898
isReportItemChild?: boolean;
9999
isActionLoading?: boolean;
100100
isInReportTableView?: boolean;
101+
isInSingleTransactionReport?: boolean;
101102
};
102103

103104
/** If merchant name is empty or (none), then it falls back to description if screen is narrow */
@@ -134,6 +135,7 @@ function TransactionItemRow({
134135
isReportItemChild = false,
135136
isActionLoading,
136137
isInReportTableView = false,
138+
isInSingleTransactionReport = false,
137139
}: TransactionItemRowProps) {
138140
const styles = useThemeStyles();
139141
const {translate} = useLocalize();
@@ -290,7 +292,10 @@ function TransactionItemRow({
290292
),
291293
[CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: (
292294
<View style={[StyleUtils.getReportTableColumnStyles(CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS)]}>
293-
<ChatBubbleCell transaction={transactionItem} />
295+
<ChatBubbleCell
296+
transaction={transactionItem}
297+
isInSingleTransactionReport={isInSingleTransactionReport}
298+
/>
294299
</View>
295300
),
296301
[CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT]: (
@@ -317,6 +322,7 @@ function TransactionItemRow({
317322
isActionLoading,
318323
isReportItemChild,
319324
isDateColumnWide,
325+
isInSingleTransactionReport,
320326
isSelected,
321327
merchantOrDescriptionName,
322328
onButtonPress,
@@ -420,6 +426,7 @@ function TransactionItemRow({
420426
<ChatBubbleCell
421427
transaction={transactionItem}
422428
containerStyles={[styles.mt2]}
429+
isInSingleTransactionReport={isInSingleTransactionReport}
423430
/>
424431
</View>
425432
</View>

0 commit comments

Comments
 (0)