Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ function ExpenseReportListItem<TItem extends ListItem>({
shouldShowUserInfo={!!reportItem?.from}
stateNum={reportItem.stateNum}
statusNum={reportItem.statusNum}
isSelected={!!reportItem.isSelected}
/>
)}
{!isLargeScreenWidth && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function ExpenseReportListItemRow({
stateNum={item.stateNum}
statusNum={item.statusNum}
isPending={item.shouldShowStatusAsPending}
isSelected={item.isSelected}
/>
</View>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ function ReportListItemHeader<TItem extends ListItem>({
containerStyles={[styles.pr3, styles.mb2]}
stateNum={reportItem.stateNum}
statusNum={reportItem.statusNum}
isSelected={!!reportItem.isSelected}
/>
<HeaderFirstRow
report={reportItem}
Expand Down
11 changes: 8 additions & 3 deletions src/components/Search/SearchList/ListItem/StatusCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import StatusBadge from '@components/StatusBadge';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {getReportStatusColorStyle, getReportStatusTranslation} from '@libs/ReportUtils';
import {getReportStatusColorStyle, getReportStatusTranslation, getStatusBadgeBackgroundColor} from '@libs/ReportUtils';

type StatusCellProps = {
/** The stateNum of the report */
Expand All @@ -18,9 +18,12 @@ type StatusCellProps = {

/** Whether the transaction is deleted */
isDeleted?: boolean;

/** Whether the parent row is selected */
isSelected?: boolean;
};

function StatusCell({stateNum, statusNum, isPending, isDeleted}: StatusCellProps) {
function StatusCell({stateNum, statusNum, isPending, isDeleted, isSelected}: StatusCellProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
Expand All @@ -32,11 +35,13 @@ function StatusCell({stateNum, statusNum, isPending, isDeleted}: StatusCellProps
return null;
}

const backgroundColor = getStatusBadgeBackgroundColor(theme, stateNum, statusNum, isDeleted, isSelected);

return (
<View style={[styles.w100, styles.justifyContentCenter, isPending && styles.offlineFeedbackPending]}>
<StatusBadge
text={statusText}
backgroundColor={reportStatusColorStyle.backgroundColor}
backgroundColor={backgroundColor}
textColor={reportStatusColorStyle.textColor}
/>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ function TransactionListItem<TItem extends ListItem>({
shouldShowUserInfo={!isDeletedTransaction && !!transactionItem?.from}
stateNum={transactionItem.report?.stateNum}
statusNum={transactionItem.report?.statusNum}
isSelected={!!transactionItem.isSelected}
/>
)}
<TransactionItemRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import StatusBadge from '@components/StatusBadge';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {getReportStatusColorStyle, getReportStatusTranslation} from '@libs/ReportUtils';
import {getReportStatusColorStyle, getReportStatusTranslation, getStatusBadgeBackgroundColor} from '@libs/ReportUtils';
import CONST from '@src/CONST';
import type {ExpenseReportListItemType, TransactionListItemType, TransactionReportGroupListItemType} from './types';
import UserInfoCellsWithArrow from './UserInfoCellsWithArrow';
Expand All @@ -20,18 +20,21 @@ function UserInfoAndActionButtonRow({
containerStyles,
stateNum,
statusNum,
isSelected,
}: {
item: TransactionReportGroupListItemType | TransactionListItemType | ExpenseReportListItemType;
shouldShowUserInfo: boolean;
containerStyles?: StyleProp<ViewStyle>;
stateNum: ExpenseReportListItemType['stateNum'];
statusNum: ExpenseReportListItemType['statusNum'];
isSelected?: boolean;
}) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
const statusText = getReportStatusTranslation({stateNum, statusNum, translate});
const reportStatusColorStyle = getReportStatusColorStyle(theme, stateNum, statusNum);
const badgeBackgroundColor = getStatusBadgeBackgroundColor(theme, stateNum, statusNum, undefined, isSelected);
const participantFromDisplayName = item.formattedFrom ?? item?.from?.displayName ?? '';
return (
<View style={[styles.pt0, styles.flexRow, styles.alignItemsCenter, shouldShowUserInfo ? styles.justifyContentBetween : styles.justifyContentEnd, styles.gap2, containerStyles]}>
Expand All @@ -53,7 +56,7 @@ function UserInfoAndActionButtonRow({
{!!statusText && !!reportStatusColorStyle && (
<StatusBadge
text={statusText}
backgroundColor={reportStatusColorStyle.backgroundColor}
backgroundColor={badgeBackgroundColor}
textColor={reportStatusColorStyle.textColor}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions src/components/TransactionItemRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ function TransactionItemRow({
stateNum={transactionItem.report?.stateNum}
statusNum={transactionItem.report?.statusNum}
isDeleted={isDeletedTransaction}
isSelected={isSelected}
/>
</View>
);
Expand Down
7 changes: 7 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13251,6 +13251,12 @@ function getReportStatusColorStyle(theme: ThemeColors, stateNum?: number, status
return undefined;
}

function getStatusBadgeBackgroundColor(theme: ThemeColors, stateNum?: number, statusNum?: number, isDeleted?: boolean, isSelected?: boolean): ColorValue | undefined {
const reportStatusColorStyle = getReportStatusColorStyle(theme, stateNum, statusNum, isDeleted);
const isUnreported = (stateNum === undefined || statusNum === undefined) && !isDeleted;
return isSelected && isUnreported ? theme.buttonHoveredBG : reportStatusColorStyle?.backgroundColor;
}

/**
* Checks if a workspace member is leaving a workspace room
* This is used to determine if we need to show special handling when a workspace member leaves a room
Expand Down Expand Up @@ -13727,6 +13733,7 @@ export {
isMoneyRequestReportEligibleForMerge,
getReportStatusTranslation,
getReportStatusColorStyle,
getStatusBadgeBackgroundColor,
getMovedActionMessage,
excludeParticipantsForDisplay,
getReceiptUploadErrorReason,
Expand Down
Loading