Skip to content

Commit 65fd4aa

Browse files
authored
Merge pull request #89521 from Expensify/claude-fixUnreportedBadgeSelectedColor
[CP Staging] Fix unreported badge invisible when expense row selected
2 parents e8c00bd + e743c03 commit 65fd4aa

8 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/components/Search/SearchList/ListItem/ExpenseReportListItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ function ExpenseReportListItem<TItem extends ListItem>({
304304
shouldShowUserInfo={!!reportItem?.from}
305305
stateNum={reportItem.stateNum}
306306
statusNum={reportItem.statusNum}
307+
isSelected={!!reportItem.isSelected}
307308
/>
308309
)}
309310
{!isLargeScreenWidth && (

src/components/Search/SearchList/ListItem/ExpenseReportListItemRow.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ function ExpenseReportListItemRow({
117117
stateNum={item.stateNum}
118118
statusNum={item.statusNum}
119119
isPending={item.shouldShowStatusAsPending}
120+
isSelected={item.isSelected}
120121
/>
121122
</View>
122123
),

src/components/Search/SearchList/ListItem/ReportListItemHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ function ReportListItemHeader<TItem extends ListItem>({
251251
containerStyles={[styles.pr3, styles.mb2]}
252252
stateNum={reportItem.stateNum}
253253
statusNum={reportItem.statusNum}
254+
isSelected={!!reportItem.isSelected}
254255
/>
255256
<HeaderFirstRow
256257
report={reportItem}

src/components/Search/SearchList/ListItem/StatusCell.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import StatusBadge from '@components/StatusBadge';
44
import useLocalize from '@hooks/useLocalize';
55
import useTheme from '@hooks/useTheme';
66
import useThemeStyles from '@hooks/useThemeStyles';
7-
import {getReportStatusColorStyle, getReportStatusTranslation} from '@libs/ReportUtils';
7+
import {getReportStatusColorStyle, getReportStatusTranslation, getStatusBadgeBackgroundColor} from '@libs/ReportUtils';
88

99
type StatusCellProps = {
1010
/** The stateNum of the report */
@@ -18,9 +18,12 @@ type StatusCellProps = {
1818

1919
/** Whether the transaction is deleted */
2020
isDeleted?: boolean;
21+
22+
/** Whether the parent row is selected */
23+
isSelected?: boolean;
2124
};
2225

23-
function StatusCell({stateNum, statusNum, isPending, isDeleted}: StatusCellProps) {
26+
function StatusCell({stateNum, statusNum, isPending, isDeleted, isSelected}: StatusCellProps) {
2427
const styles = useThemeStyles();
2528
const theme = useTheme();
2629
const {translate} = useLocalize();
@@ -32,11 +35,13 @@ function StatusCell({stateNum, statusNum, isPending, isDeleted}: StatusCellProps
3235
return null;
3336
}
3437

38+
const backgroundColor = getStatusBadgeBackgroundColor(theme, stateNum, statusNum, isDeleted, isSelected);
39+
3540
return (
3641
<View style={[styles.w100, styles.justifyContentCenter, isPending && styles.offlineFeedbackPending]}>
3742
<StatusBadge
3843
text={statusText}
39-
backgroundColor={reportStatusColorStyle.backgroundColor}
44+
backgroundColor={backgroundColor}
4045
textColor={reportStatusColorStyle.textColor}
4146
/>
4247
</View>

src/components/Search/SearchList/ListItem/TransactionListItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ function TransactionListItem<TItem extends ListItem>({
237237
shouldShowUserInfo={!isDeletedTransaction && !!transactionItem?.from}
238238
stateNum={transactionItem.report?.stateNum}
239239
statusNum={transactionItem.report?.statusNum}
240+
isSelected={!!transactionItem.isSelected}
240241
/>
241242
)}
242243
<TransactionItemRow

src/components/Search/SearchList/ListItem/UserInfoAndActionButtonRow.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import StatusBadge from '@components/StatusBadge';
99
import useLocalize from '@hooks/useLocalize';
1010
import useTheme from '@hooks/useTheme';
1111
import useThemeStyles from '@hooks/useThemeStyles';
12-
import {getReportStatusColorStyle, getReportStatusTranslation} from '@libs/ReportUtils';
12+
import {getReportStatusColorStyle, getReportStatusTranslation, getStatusBadgeBackgroundColor} from '@libs/ReportUtils';
1313
import CONST from '@src/CONST';
1414
import type {ExpenseReportListItemType, TransactionListItemType, TransactionReportGroupListItemType} from './types';
1515
import UserInfoCellsWithArrow from './UserInfoCellsWithArrow';
@@ -20,18 +20,21 @@ function UserInfoAndActionButtonRow({
2020
containerStyles,
2121
stateNum,
2222
statusNum,
23+
isSelected,
2324
}: {
2425
item: TransactionReportGroupListItemType | TransactionListItemType | ExpenseReportListItemType;
2526
shouldShowUserInfo: boolean;
2627
containerStyles?: StyleProp<ViewStyle>;
2728
stateNum: ExpenseReportListItemType['stateNum'];
2829
statusNum: ExpenseReportListItemType['statusNum'];
30+
isSelected?: boolean;
2931
}) {
3032
const styles = useThemeStyles();
3133
const theme = useTheme();
3234
const {translate} = useLocalize();
3335
const statusText = getReportStatusTranslation({stateNum, statusNum, translate});
3436
const reportStatusColorStyle = getReportStatusColorStyle(theme, stateNum, statusNum);
37+
const badgeBackgroundColor = getStatusBadgeBackgroundColor(theme, stateNum, statusNum, undefined, isSelected);
3538
const participantFromDisplayName = item.formattedFrom ?? item?.from?.displayName ?? '';
3639
return (
3740
<View style={[styles.pt0, styles.flexRow, styles.alignItemsCenter, shouldShowUserInfo ? styles.justifyContentBetween : styles.justifyContentEnd, styles.gap2, containerStyles]}>
@@ -53,7 +56,7 @@ function UserInfoAndActionButtonRow({
5356
{!!statusText && !!reportStatusColorStyle && (
5457
<StatusBadge
5558
text={statusText}
56-
backgroundColor={reportStatusColorStyle.backgroundColor}
59+
backgroundColor={badgeBackgroundColor}
5760
textColor={reportStatusColorStyle.textColor}
5861
/>
5962
)}

src/components/TransactionItemRow/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ function TransactionItemRow({
680680
stateNum={transactionItem.report?.stateNum}
681681
statusNum={transactionItem.report?.statusNum}
682682
isDeleted={isDeletedTransaction}
683+
isSelected={isSelected}
683684
/>
684685
</View>
685686
);

src/libs/ReportUtils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13255,6 +13255,12 @@ function getReportStatusColorStyle(theme: ThemeColors, stateNum?: number, status
1325513255
return undefined;
1325613256
}
1325713257

13258+
function getStatusBadgeBackgroundColor(theme: ThemeColors, stateNum?: number, statusNum?: number, isDeleted?: boolean, isSelected?: boolean): ColorValue | undefined {
13259+
const reportStatusColorStyle = getReportStatusColorStyle(theme, stateNum, statusNum, isDeleted);
13260+
const isUnreported = (stateNum === undefined || statusNum === undefined) && !isDeleted;
13261+
return isSelected && isUnreported ? theme.buttonHoveredBG : reportStatusColorStyle?.backgroundColor;
13262+
}
13263+
1325813264
/**
1325913265
* Checks if a workspace member is leaving a workspace room
1326013266
* This is used to determine if we need to show special handling when a workspace member leaves a room
@@ -13731,6 +13737,7 @@ export {
1373113737
isMoneyRequestReportEligibleForMerge,
1373213738
getReportStatusTranslation,
1373313739
getReportStatusColorStyle,
13740+
getStatusBadgeBackgroundColor,
1373413741
getMovedActionMessage,
1373513742
excludeParticipantsForDisplay,
1373613743
getReceiptUploadErrorReason,

0 commit comments

Comments
 (0)