Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b7a9ef5
Show up to three report fields per row and edit them inline
MelvinBot Sep 9, 2026
e0efa1c
Fix failing checks: add isTax to test fixture, drop unused type expor…
MelvinBot Sep 9, 2026
c193348
Use useResponsiveLayoutOnWideRHP so the report fields grid sees the r…
MelvinBot Sep 10, 2026
49fd55e
Keep the calendar icon when the DatePicker clear button is hidden
MelvinBot Sep 10, 2026
424abaa
Open list report fields in an anchored dropdown with a caret instead …
MelvinBot Sep 10, 2026
9a62cfa
Pad the report field dropdown search input, drop its Recent section a…
MelvinBot Sep 10, 2026
c79529e
Align report field inputs at the top of a row, hold violations until …
MelvinBot Sep 10, 2026
cf85772
Merge remote-tracking branch 'origin/main' into claude-reportFieldsGr…
MelvinBot Sep 10, 2026
9e39803
Scope the report field violation reads to this report instead of the …
MelvinBot Sep 10, 2026
4e111e6
Run oxfmt on useSaveReportField
MelvinBot Sep 12, 2026
b1e091c
Address design feedback on report field grid
MelvinBot Sep 12, 2026
d098970
Save an empty value when an optional report field is cleared
MelvinBot Sep 13, 2026
e9dda73
Merge remote-tracking branch 'origin/main' into claude-reportFieldsGr…
MelvinBot Sep 15, 2026
b64ccd8
Stack report fields one per row on one-expense reports
MelvinBot Sep 15, 2026
ed37e25
Cover the one-per-row layout at the MoneyReportView level
MelvinBot Sep 15, 2026
ead06c4
Merge branch 'main' into claude-reportFieldsGridInlineEditing
MelvinBot Sep 16, 2026
01b8802
Fix: keep the list field caret in place when its dropdown opens
MelvinBot Sep 17, 2026
c2fc1ec
Merge remote-tracking branch 'origin/main' into claude-reportFieldsGr…
MelvinBot Sep 19, 2026
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
3 changes: 1 addition & 2 deletions config/eslint/eslint.seatbelt.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
"../../src/components/ReceiptHoverZoom/useReceiptHoverZoom.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/ReportActionAvatars/useReportPreviewSenderID.ts" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/components/ReportActionItem/IssueCardMessage.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/components/ReportActionItem/MoneyReportView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/components/ReportActionItem/MoneyReportView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/ReportActionItem/MoneyRequestReceiptView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/components/ReportActionItem/MoneyRequestReceiptView.tsx" "react-hooks/set-state-in-effect" 1
"../../src/components/ReportActionItem/MoneyRequestReceiptView.tsx" "rulesdir/no-direct-personal-details-list" 3
Expand Down Expand Up @@ -945,7 +945,6 @@
"../../src/pages/domain/Members/MoveUserBetweenGroupsPage.tsx" "rulesdir/no-direct-personal-details-list" 1
"../../src/pages/domain/Members/TwoFactorAuth/DomainMemberForceTwoFactorAuthPage.tsx" "rulesdir/no-direct-personal-details-list" 1
"../../src/pages/domain/Members/TwoFactorAuth/DomainMemberResetTwoFactorAuthPage.tsx" "rulesdir/no-direct-personal-details-list" 1
"../../src/pages/DynamicEditReportFieldPage.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/pages/DynamicReportChangeApproverPage.tsx" "react-hooks/set-state-in-effect" 1
"../../src/pages/DynamicReportChangeWorkspacePage.tsx" "rulesdir/no-direct-personal-details-list" 3
"../../src/pages/DynamicReportDetailsPage.tsx" "@typescript-eslint/no-unsafe-type-assertion" 3
Expand Down
6 changes: 6 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7093,6 +7093,12 @@ const CONST = {

REPORT_FIELD_TITLE_FIELD_ID: 'text_title',

/** How many report fields are shown side by side in the report view on a wide layout */
REPORT_FIELDS_PER_ROW: 3,

/** Below this many options, a report field list is short enough to scan without a search input */
REPORT_FIELD_LIST_SEARCH_THRESHOLD: 8,

MOBILE_PAGINATION_SIZE: 15,
WEB_PAGINATION_SIZE: 30,

Expand Down
9 changes: 7 additions & 2 deletions src/components/DatePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ function DatePicker({
forwardedFSClass,
shouldDeferShowUntilPositioned = false,
shouldDismissKeyboardBeforeShow = false,
wrapperStyle,
onBlur,
rightHandSideComponent,
onPickerVisibilityChange,
shouldHideCalendarIcon = false,
Expand Down Expand Up @@ -227,13 +229,15 @@ function DatePicker({
<>
<View
ref={anchorRef}
style={styles.mv2}
style={[styles.mv2, wrapperStyle]}
>
<TextInput
ref={combinedTextInputRef}
inputID={inputID}
forceActiveLabel
icon={selectedDate || shouldHideCalendarIcon ? null : icons.Calendar}
// The icon, the clear button and any `rightHandSideComponent` share the right-hand slot. The icon
// gives way when the caller asks for the slot outright, or to a clear button that will actually render.
icon={shouldHideCalendarIcon || (selectedDate && !shouldHideClearButton) ? null : icons.Calendar}
iconContainerStyle={styles.pr0}
label={label}
accessibilityLabel={label}
Expand All @@ -246,6 +250,7 @@ function DatePicker({
disabled={disabled}
hideFocusedState={shouldDismissKeyboardBeforeShow}
onPress={shouldDismissKeyboardBeforeShow ? handlePress : () => showDatePickerModal()}
onBlur={onBlur}
onSubmitEditing={() => showDatePickerModal()}
onKeyPress={handleInputKeyPress}
textInputContainerStyles={isModalVisible ? styles.borderColorFocus : {}}
Expand Down
9 changes: 9 additions & 0 deletions src/components/DatePicker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type {ForwardedFSClassProps} from '@libs/Fullstory/types';

import type {OnyxFormValuesMapping} from '@src/ONYXKEYS';

import type {StyleProp, ViewStyle} from 'react-native';

type DatePickerBaseProps = ForwardedFSClassProps & {
/**
* The datepicker supports any value that `new Date()` can parse.
Expand Down Expand Up @@ -70,6 +72,13 @@ type DateInputWithPickerProps = DatePickerBaseProps &
*/
shouldDismissKeyboardBeforeShow?: boolean;

/**
* Style for the view that wraps the input and anchors the calendar. It carries a vertical margin by default,
* which a caller laying the field out itself can override, for example to line the input up with a plain
* `TextInput` beside it.
*/
wrapperStyle?: StyleProp<ViewStyle>;

/**
* Reports whether the calendar is open. Opening the picker blurs the input, so this is the signal for "the
* user is on this field" rather than `onFocus`, and it is what drives the input's focused border.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,8 @@ function MoneyRequestReportActionsListContent({reportIDFromRoute, onLayout}: Mon
onViewableItemsChanged={onViewableItemsChanged}
onEndReached={onEndReached}
onStartReached={onStartReached}
contentContainerStyle={shouldUseNarrowLayout ? styles.pt4 : styles.pt3}
// 20px between the report header and the first row of content, which is the report field inputs when the report has fields.
contentContainerStyle={styles.pt5}
isLoadingInitialActions={isInitialReportLoadPending}
/* This list is not inverted, so the footer is the bottom of the message feed —
the same position the indicator occupies in the inverted ReportActionsList. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ function MoneyRequestReportEmptyStateView({report, policy, onLayout}: MoneyReque
const styles = useThemeStyles();

return (
<ScrollView contentContainerStyle={styles.flexGrow1}>
// `pt5` matches the 20px the unified list puts between the report header and its first row.
<ScrollView contentContainerStyle={[styles.flexGrow1, styles.pt5]}>
<MoneyRequestViewReportFields
report={report}
policy={policy}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';

import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useOnyx from '@hooks/useOnyx';
import useResponsiveLayoutOnWideRHP from '@hooks/useResponsiveLayoutOnWideRHP';
import useSaveReportField from '@hooks/useSaveReportField';
import useThemeStyles from '@hooks/useThemeStyles';

import {clearReportFieldKeyErrors} from '@libs/actions/Report';
import {resolveReportFieldValue} from '@libs/Formula';
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import Navigation from '@libs/Navigation/Navigation';
import {
getFieldViolation,
getFieldViolationTranslation,
Expand All @@ -26,16 +25,17 @@ import type {ThemeStyles} from '@styles/index';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {DYNAMIC_ROUTES} from '@src/ROUTES';
import type {Policy, PolicyReportField, Report, ReportViolationName} from '@src/types/onyx';
import type {PendingAction} from '@src/types/onyx/OnyxCommon';

import type {StyleProp, ViewStyle} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';

import {Str} from 'expensify-common';
import React, {useMemo} from 'react';
import {View} from 'react-native';

import ReportFieldInlineInput from './ReportFieldInlineInput';

type MoneyRequestViewReportFieldsProps = {
report: OnyxEntry<Report>;

Expand All @@ -44,6 +44,16 @@ type MoneyRequestViewReportFieldsProps = {

/** Indicates whether we have any pending actions from parent component */
pendingAction?: PendingAction;

/** Extra styles for the block. Each call site sits in a container with its own padding, so it sets the spacing it needs. */
style?: StyleProp<ViewStyle>;

/**
* Stacks the fields one per row at any width, instead of filling rows of `CONST.REPORT_FIELDS_PER_ROW`.
* A one-expense report reads as a single expense rather than a table, so its fields stay vertical there.
* @default false
*/
shouldUseSingleColumn?: boolean;
};

type EnrichedPolicyReportField = {
Expand All @@ -54,39 +64,43 @@ type EnrichedPolicyReportField = {
violationTranslation: string;
} & PolicyReportField;

function ReportFieldView(reportField: EnrichedPolicyReportField, report: OnyxEntry<Report>, styles: ThemeStyles, pendingAction?: PendingAction) {
function ReportFieldView(
reportField: EnrichedPolicyReportField,
report: OnyxEntry<Report>,
policy: OnyxEntry<Policy>,
styles: ThemeStyles,
onSaveValue: (reportField: PolicyReportField, value: string) => void,
pendingAction?: PendingAction,
) {
return (
<OfflineWithFeedback
// Need to return undefined when we have pendingAction to avoid the duplicate pending action
pendingAction={pendingAction ? undefined : report?.pendingFields?.[reportField.fieldKey as keyof typeof report.pendingFields]}
errorRowStyles={styles.ph5}
key={`menuItem-${reportField.fieldKey}`}
onClose={() => clearReportFieldKeyErrors(report?.reportID, reportField.fieldKey)}
<View
key={`reportField-${reportField.fieldKey}`}
style={styles.flex1}
>
<MenuItemWithTopDescription
description={Str.UCFirst(reportField.name)}
title={reportField.fieldValue}
onPress={() => {
if (!report?.policyID) {
return;
}

Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.EDIT_REPORT_FIELD.getRoute(report.policyID, reportField.fieldID)));
}}
shouldShowRightIcon={!reportField.isFieldDisabled}
wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]}
shouldGreyOutWhenDisabled={false}
numberOfLinesTitle={0}
interactive={!reportField.isFieldDisabled}
titleWithTooltips={[]}
brickRoadIndicator={reportField.violation ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={reportField.violationTranslation}
/>
</OfflineWithFeedback>
<OfflineWithFeedback
// Need to return undefined when we have pendingAction to avoid the duplicate pending action
pendingAction={pendingAction ? undefined : report?.pendingFields?.[reportField.fieldKey as keyof typeof report.pendingFields]}
errors={report?.errorFields?.[reportField.fieldKey]}
onClose={() => clearReportFieldKeyErrors(report?.reportID, reportField.fieldKey)}
>
<ReportFieldInlineInput
reportField={reportField}
fieldKey={reportField.fieldKey}
value={reportField.fieldValue}
isDisabled={reportField.isFieldDisabled}
errorText={reportField.violationTranslation}
fieldList={policy?.fieldList}
onSaveValue={(value) => onSaveValue(reportField, value)}
/>
</OfflineWithFeedback>
</View>
);
}
function MoneyRequestViewReportFields({report, policy, pendingAction}: MoneyRequestViewReportFieldsProps) {
function MoneyRequestViewReportFields({report, policy, pendingAction, style, shouldUseSingleColumn = false}: MoneyRequestViewReportFieldsProps) {
const styles = useThemeStyles();
// The report view is a RightModalNavigator screen shown as a wide RHP, where `useResponsiveLayout` reports a narrow layout at any pane width.
const {shouldUseNarrowLayout} = useResponsiveLayoutOnWideRHP();
const saveReportField = useSaveReportField(report, policy);
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${getNonEmptyStringOnyxID(report?.reportID)}`);
const {getCurrencyDecimals} = useCurrencyListActions();
Expand Down Expand Up @@ -128,10 +142,35 @@ function MoneyRequestViewReportFields({report, policy, pendingAction}: MoneyRequ
return null;
}

const columnCount = shouldUseNarrowLayout || shouldUseSingleColumn ? 1 : CONST.REPORT_FIELDS_PER_ROW;
const fieldRows: EnrichedPolicyReportField[][] = [];
for (let index = 0; index < sortedPolicyReportFields.length; index += columnCount) {
fieldRows.push(sortedPolicyReportFields.slice(index, index + columnCount));
}

return (
<View style={styles.mb3}>
{sortedPolicyReportFields.map((reportField) => {
return ReportFieldView(reportField, report, styles, pendingAction);
<View style={[styles.ph5, styles.mb3, styles.gap3, style]}>
{fieldRows.map((fieldRow) => {
const rowKey = `reportFieldRow-${fieldRow.at(0)?.fieldKey}`;

return (
<View
key={rowKey}
testID="reportFieldsRow"
// Each cell sizes to its own content and hugs the top of the row, so a field showing an error
// message grows downwards instead of stretching the cells beside it and shifting their inputs.
style={[styles.flexRow, styles.gap3, styles.alignItemsStart]}
>
{fieldRow.map((reportField) => ReportFieldView(reportField, report, policy, styles, saveReportField, pendingAction))}
{/* A partly filled last row is padded out so its fields stay the same width as the rows above it. */}
{Array.from({length: columnCount - fieldRow.length}, (_unused, index) => (
<View
key={`${rowKey}-spacer-${index}`}
style={styles.flex1}
/>
))}
</View>
);
})}
</View>
);
Expand Down
Loading
Loading