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
19 changes: 17 additions & 2 deletions src/components/ReportSearchHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ function ReportSearchHeader({report, style, transactions, avatarBorderColor}: Re
const styles = useThemeStyles();
const {isLargeScreenWidth} = useResponsiveLayout();

const statusContainerStyle = useMemo(() => {
return [isLargeScreenWidth ? styles.mt1 : styles.mt0Half, report?.shouldShowStatusAsPending && styles.offlineFeedbackPending];
}, [isLargeScreenWidth, styles.mt1, styles.mt0Half, report?.shouldShowStatusAsPending, styles.offlineFeedbackPending]);

const middleContent = useMemo(() => {
return (
<AvatarWithDisplayName
Expand All @@ -21,10 +25,21 @@ function ReportSearchHeader({report, style, transactions, avatarBorderColor}: Re
avatarBorderColor={avatarBorderColor}
customDisplayNameStyle={styles.fontWeightNormal}
parentNavigationSubtitleTextStyles={[styles.textLineHeightNormal, styles.minHeight4, styles.mt1, !isLargeScreenWidth && styles.textMicro]}
parentNavigationStatusContainerStyles={isLargeScreenWidth ? styles.mt1 : styles.mt0Half}
parentNavigationStatusContainerStyles={statusContainerStyle}
/>
);
}, [report, transactions, avatarBorderColor, styles.fontWeightNormal, styles.textLineHeightNormal, styles.minHeight4, styles.mt1, isLargeScreenWidth, styles.textMicro, styles.mt0Half]);
}, [
report,
transactions,
avatarBorderColor,
styles.fontWeightNormal,
styles.textLineHeightNormal,
styles.minHeight4,
styles.mt1,
isLargeScreenWidth,
styles.textMicro,
statusContainerStyle,
]);

return (
<View
Expand Down
6 changes: 2 additions & 4 deletions src/components/ReportSearchHeader/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type {ColorValue, StyleProp, ViewStyle} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {TransactionListItemType} from '@components/SelectionListWithSections/types';
import type {Report} from '@src/types/onyx';
import type {ExpenseReportListItemType, TransactionListItemType} from '@components/SelectionListWithSections/types';

type ReportSearchHeaderProps = {
/** Report, if we're showing the details for one and using AvatarWithDisplay */
report?: OnyxEntry<Report>;
report?: ExpenseReportListItemType;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the data type passed to ReportSearchHeader is ExpenseReportListItemType.

and OnyxEntry is only part of it. Since isReportStatePending is not part of OnyxEntry<Report>, I need to use the full type.


/** Additional styles to add to the component */
style?: StyleProp<ViewStyle>;
Expand Down
2 changes: 2 additions & 0 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,13 @@ function Search({
queryJSON,
isActionLoadingSet,
cardFeeds,
isOffline,
allTransactionViolations: violations,
});
return [filteredData1, filteredData1.length, allLength];
}, [
searchKey,
isOffline,
exportReportActions,
validGroupBy,
isDataLoaded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function ExpenseReportListItemRow({
<StatusCell
stateNum={item.stateNum}
statusNum={item.statusNum}
isPending={item.shouldShowStatusAsPending}
/>
</View>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ type StatusCellProps = {

/** The statusNum of the report */
statusNum?: number;

/** Whether the report's state/status is pending */
isPending?: boolean;
};

function StatusCell({stateNum, statusNum}: StatusCellProps) {
function StatusCell({stateNum, statusNum, isPending}: StatusCellProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
Expand All @@ -41,7 +44,7 @@ function StatusCell({stateNum, statusNum}: StatusCellProps) {
}

return (
<View style={[styles.w100, styles.justifyContentCenter]}>
<View style={[styles.w100, styles.justifyContentCenter, isPending && styles.offlineFeedbackPending]}>
<View style={[styles.reportStatusContainer, backgroundColorStyle]}>
<Text style={[styles.reportStatusText, textColorStyle]}>{statusText}</Text>
</View>
Expand Down
3 changes: 3 additions & 0 deletions src/components/SelectionListWithSections/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ type TransactionReportGroupListItemType = TransactionGroupListItemType & {groupe
/** The date the report was exported */
exported?: string;

/** Whether the status field should be shown in a pending state */
shouldShowStatusAsPending?: boolean;

/**
* Whether we should show the report year.
* This is true if at least one report in the dataset was created in past years
Expand Down
8 changes: 8 additions & 0 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type GetReportSectionsParams = {
translate: LocalizedTranslate;
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
isActionLoadingSet: ReadonlySet<string> | undefined;
isOffline: boolean | undefined;
allTransactionViolations: OnyxCollection<OnyxTypes.TransactionViolation[]>;
bankAccountList: OnyxEntry<OnyxTypes.BankAccountList>;
reportActions?: Record<string, OnyxTypes.ReportAction[]>;
Expand Down Expand Up @@ -417,6 +418,7 @@ type GetSectionsParams = {
archivedReportsIDList?: ArchivedReportsIDSet;
queryJSON?: SearchQueryJSON;
isActionLoadingSet?: ReadonlySet<string>;
isOffline?: boolean;
cardFeeds?: OnyxCollection<OnyxTypes.CardFeeds>;
allTransactionViolations?: OnyxCollection<OnyxTypes.TransactionViolation[]>;
};
Expand Down Expand Up @@ -1863,6 +1865,7 @@ function getReportSections({
currentAccountID,
currentUserEmail,
translate,
isOffline,
formatPhoneNumber,
isActionLoadingSet,
allTransactionViolations,
Expand Down Expand Up @@ -1954,6 +1957,8 @@ function getReportSections({
const policyFromKey = getPolicyFromKey(data, reportItem);
const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${reportItem?.policyID ?? String(CONST.DEFAULT_NUMBER_ID)}`] ?? policyFromKey;

const shouldShowStatusAsPending = !!isOffline && reportItem?.pendingFields?.nextStep === CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE;

const hasAnyViolationsForReport = hasAnyViolations(
reportItem.reportID,
allTransactionViolations ?? allViolations,
Expand Down Expand Up @@ -1987,6 +1992,7 @@ function getReportSections({
formattedTo,
formattedStatus,
transactions,
shouldShowStatusAsPending,
...(reportPendingAction ? {pendingAction: reportPendingAction} : {}),
shouldShowYear: shouldShowYearCreatedReport,
shouldShowYearSubmitted: shouldShowYearSubmittedReport,
Expand Down Expand Up @@ -2453,6 +2459,7 @@ function getSections({
archivedReportsIDList,
queryJSON,
isActionLoadingSet,
isOffline,
cardFeeds,
allTransactionViolations,
}: GetSectionsParams) {
Expand All @@ -2471,6 +2478,7 @@ function getSections({
currentAccountID,
currentUserEmail,
translate,
isOffline,
formatPhoneNumber,
isActionLoadingSet,
allTransactionViolations,
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/Search/SearchUIUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ const transactionReportGroupListItems = [
},
hasVisibleViolations: false,
isOneTransactionReport: true,
shouldShowStatusAsPending: false,
isWaitingOnBankAccount: false,
keyForList: '123456789',
managerID: 18439984,
Expand Down Expand Up @@ -1172,6 +1173,7 @@ const transactionReportGroupListItems = [
},
hasVisibleViolations: true,
isOneTransactionReport: true,
shouldShowStatusAsPending: false,
isWaitingOnBankAccount: false,
keyForList: '11111',
managerID: 18439984,
Expand Down Expand Up @@ -1280,6 +1282,7 @@ const transactionReportGroupListItems = [
formattedTo: 'Approver',
hasVisibleViolations: false,
isOneTransactionReport: false,
shouldShowStatusAsPending: false,
isOwnPolicyExpenseChat: false,
isWaitingOnBankAccount: false,
managerID: 1111111,
Expand Down Expand Up @@ -1460,6 +1463,7 @@ const transactionReportGroupListItems = [
},
hasVisibleViolations: false,
isOneTransactionReport: true,
shouldShowStatusAsPending: false,
isWaitingOnBankAccount: false,
keyForList: reportID5,
managerID: 18439984,
Expand Down
Loading