App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-11-14] [$175] Report title-Report title field accept multiline text

Open lanitochka17 opened this issue 1 month ago • 35 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: undefined Reproducible in staging?: Yes Reproducible in production?: yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/Expensify/issues/572854 Email or phone of affected tester (no customers): Issue reported by: Applause Internal Team Bug source: Device used: App Component:

Action Performed:

  1. Open the app.
  2. Go to workspace settings > Reports.
  3. Click Default report title.
  4. Enter multiline text with some mark down.

Expected Result:

default report title field should accept only single line title

Actual Result:

it accepts multiline text in default report title

Workaround:

Unknown

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome / Safari

Screenshots/Videos

https://github.com/user-attachments/assets/7c6f1add-bbf9-438d-acb8-762cae583efa

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

lanitochka17 avatar Oct 22 '26 15:10 lanitochka17

Proposal

Please re-state the problem that we are trying to solve in this issue.

The workspace Default report title field lets you press Enter and save a title with line breaks. It should accept a single line only.

What is the root cause of that problem?

The input uses autoGrowHeight, which turns it into a multiline textarea. Because of that, Enter inserts a new line instead of submitting the form, and nothing removes line breaks before the title is saved.

History

What changes do you think we should make in order to solve the problem?

Use the same pattern as the report title edit page, EditReportFieldText.tsx. All changes are in ReportsDefaultTitle.tsx:

  1. Replace autoGrowHeight and maxAutoGrowHeight with autoGrowSingleLine. The text still wraps, but Enter submits the form instead of adding a new line (InputWrapper.tsx:50).
  2. In submitForm, convert line breaks to spaces with StringUtils.lineBreaksToSpaces before saving, because pasted text can still contain them. EditReportFieldText.tsx does the same.
  3. Run validateCustomName on the converted value.
  4. Optional: apply lineBreaksToSpaces to customNameDefaultValue too, so titles already saved with line breaks show as one line.

What alternative solutions did you explore? (Optional)

  • Remove auto-grow entirely. This is simpler, but long formulas would scroll sideways again, which undoes the approved design from the ORTF PR.
  • Strip new lines in onChangeText. Enter would do nothing, and the cursor could jump.

Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/104758) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run

MelvinBot avatar Oct 22 '26 15:10 MelvinBot

Proposal

Please re-state the problem that we are trying to solve in this issue.

In Workspace settings > Reports > Default report title, the input accepts multiline text. Pressing Enter, or pasting text with line breaks, inserts new lines into the title template. The default report title should be a single-line value.

What is the root cause of that problem?

I couldn't confirm this against the source, and Kimi's analysis was empty, so this is from my recollection of the code. The Default report title page (src/pages/workspace/rules/RulesCustomNamePage.tsx) renders its TextInput through InputWrapper with multiline and autoGrowHeight (and markdown highlighting) enabled. This lets long formulas wrap. A multiline TextInput on web is a <textarea>, which allows newline characters from both Enter and paste. Nothing in the form's validate or onSubmit strips or rejects \n, so the stored customName can contain line breaks.

What changes do you think we should make in order to solve the problem?

  1. In RulesCustomNamePage.tsx, make the input single-line by removing multiline, autoGrowHeight and maxAutoGrowHeight. Keep the other props (isMarkdownEnabled, maxLength, label and so on). A single-line input (<input type="text"> on web, a single-line TextInput on native) rejects Enter and strips line breaks on paste. Enter then triggers the form's submit via onSubmitEditing.
<InputWrapper
    InputComponent={TextInput}
    inputID={INPUT_IDS.CUSTOM_NAME}
    label={translate('workspace.rules.expenseReportRules.customNameInputLabel')}
    aria-label={translate('workspace.rules.expenseReportRules.customNameInputLabel')}
    role={CONST.ROLE.PRESENTATION}
    ref={inputCallbackRef}
    defaultValue={customName}
    maxLength={CONST.WORKSPACE_REPORT_FIELD_POLICY_MAX_LENGTH /* keep the existing limit */}
    // removed: multiline, autoGrowHeight, maxAutoGrowHeight
/>
  1. As defense in depth, normalize the value on submit so that no \n or \r can be saved from any path, such as old drafts or other clients:
const sanitizedName = values[INPUT_IDS.CUSTOM_NAME].replace(/[\r\n]+/g, ' ').trim();
Policy.setPolicyDefaultReportTitle(policyID, sanitizedName);
  1. If product wants long formulas to keep wrapping visually, use the alternative below instead of step 1.

What alternative solutions did you explore? (Optional)

  • Keep multiline and autoGrowHeight, and strip newlines in onChangeText with submitBehavior="submit". This keeps visual wrapping, but it is more complex. InputWrapper and FormProvider manage the value, so sanitizing means making the input controlled. It also adds platform-specific Enter handling. I would only use it if wrapping is required.
  • Add a validation error when the value contains a newline. This is worse UX than preventing the input, since the user can't type or paste the character in the first place. It's also unnecessary once the input is single-line.

Testing

  1. Go to Workspace settings > Reports > Default report title.
  2. Press Enter in the field. No new line should be inserted, and the form should submit.
  3. Paste multi-line text (for example Line1\nLine2 **bold**). The newlines should be removed or collapsed and the text should appear on one line.
  4. Save and reopen the page. The saved title should be a single line, and a report using the title should render correctly.
  5. Verify on web (Chrome), iOS and Android, and check that a long title still respects maxLength and remains editable.
  6. Add a unit test (or a UI test) that the submit handler strips \n and \r from the value before calling the policy action.

Abdallah-1551 avatar Oct 22 '26 15:10 Abdallah-1551

Triggered auto assignment to Contributor-plus team member for initial proposal review - @rojiphil (External)

melvin-bot[bot] avatar Oct 22 '26 15:10 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022113291405478224182

melvin-bot[bot] avatar Oct 22 '26 15:10 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0170d6b02e9440e604

Proposal

Please re-state the problem that we are trying to solve in this issue.

In Workspace settings > Reports > Default report title, the title input field accepts multiline text (hitting Enter creates a newline in the input and line breaks are saved into the default report title). The field should only accept a single-line title.

What is the root cause of that problem?

In src/pages/workspace/reports/ReportsDefaultTitle.tsx:131-140:

<InputWrapper
    InputComponent={TextInput}
    role={CONST.ROLE.PRESENTATION}
    inputID={INPUT_IDS.DEFAULT_TITLE}
    defaultValue={customNameDefaultValue}
    label={translate('workspace.reports.customNameInputLabel')}
    aria-label={translate('workspace.reports.customNameInputLabel')}
    maxAutoGrowHeight={variables.textInputAutoGrowMaxHeight}
    spellCheck={false}
    autoFocus
    autoGrowHeight
    ref={(el: BaseTextInputRef | null): void => {
        if (!isInputInitializedRef.current) {
            updateMultilineInputRange(el);
        }
        isInputInitializedRef.current = true;
    }}
/>
  1. ReportsDefaultTitle.tsx configures the input with autoGrowHeight and maxAutoGrowHeight.
  2. In BaseTextInput/implementation/index.tsx:325, autoGrowHeight turns the input into a multiline input (multiline: true, which renders a <textarea> on Web).
  3. In a multiline input, pressing the Enter key inserts a \n character rather than submitting the form.
  4. Furthermore, in submitForm (line 84), values.defaultTitle is passed directly to setPolicyDefaultReportTitle without normalizing line breaks (\r\n), so pasted multiline text or entered newlines are permanently saved into policy settings.
  5. In contrast, EditReportFieldText.tsx (the canonical implementation for editing report field titles and report names, PR #97489) uses autoGrowSingleLine and StringUtils.lineBreaksToSpaces(values[fieldKey]).

What changes do you think we should make in order to solve the problem?

Align ReportsDefaultTitle.tsx with the pattern established in EditReportFieldText.tsx:

1. In src/pages/workspace/reports/ReportsDefaultTitle.tsx:

  1. Replace autoGrowHeight and maxAutoGrowHeight with autoGrowSingleLine. This allows long title formulas to wrap smoothly without turning the field into a multiline <textarea>. Pressing Enter immediately submits the form.
  2. In validateCustomName and submitForm, sanitize the title using StringUtils.lineBreaksToSpaces before validation and persistence so that pasted text containing line breaks is collapsed into spaces:
--- a/src/pages/workspace/reports/ReportsDefaultTitle.tsx
+++ b/src/pages/workspace/reports/ReportsDefaultTitle.tsx
@@ -20,6 +20,7 @@ import Navigation from '@libs/Navigation/Navigation';
 import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
 import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
 import {getTitleErrorField, hasCircularReferences, isTitleEmpty} from '@libs/PolicyUtils';
+import StringUtils from '@libs/StringUtils';
 import {clearPolicyDefaultReportTitleError, setPolicyDefaultReportTitle} from '@userActions/Policy/Policy';
 import CONST from '@src/CONST';
 import ONYXKEYS from '@src/ONYXKEYS';
@@ -51,7 +52,8 @@ function ReportsDefaultTitle({route}: ReportsDefaultTitleProps) {
     const customNameDefaultValue = getReportNameValue();

     const validateCustomName = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.REPORTS_DEFAULT_TITLE_MODAL_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.REPORTS_DEFAULT_TITLE_MODAL_FORM> => {
-        const defaultTitle = values.defaultTitle?.trim();
+        const defaultTitle = StringUtils.lineBreaksToSpaces(values.defaultTitle).trim();
         const errors: FormInputErrors<typeof ONYXKEYS.FORMS.REPORTS_DEFAULT_TITLE_MODAL_FORM> = {};
         if (isTitleEmpty(defaultTitle)) {
             errors.defaultTitle = translate('common.error.fieldRequired');
@@ -82,7 +84,8 @@ function ReportsDefaultTitle({route}: ReportsDefaultTitleProps) {
     });

     const submitForm = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.REPORTS_DEFAULT_TITLE_MODAL_FORM>) => {
-        setPolicyDefaultReportTitle(policyID, values.defaultTitle, policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE], getReviewWorkspaceSettingsTaskCompletion());
+        const sanitizedTitle = StringUtils.lineBreaksToSpaces(values.defaultTitle).trim();
+        setPolicyDefaultReportTitle(policyID, sanitizedTitle, policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE], getReviewWorkspaceSettingsTaskCompletion());
         Navigation.goBack();
     };

@@ -131,10 +134,9 @@ function ReportsDefaultTitle({route}: ReportsDefaultTitleProps) {
                             defaultValue={customNameDefaultValue}
                             label={translate('workspace.reports.customNameInputLabel')}
                             aria-label={translate('workspace.reports.customNameInputLabel')}
-                            maxAutoGrowHeight={variables.textInputAutoGrowMaxHeight}
+                            autoGrowSingleLine
                             spellCheck={false}
                             autoFocus
-                            autoGrowHeight
                             ref={(el: BaseTextInputRef | null): void => {
                                 if (!isInputInitializedRef.current) {
                                     updateMultilineInputRange(el);

Why this solution is optimal:

  1. Architectural Parity: Matches EditReportFieldText.tsx:103 exactly, following the design decision from PR #97489 ("Let single-field edit input grow to reduce wasted white space").
  2. Best UX: Long formulas (e.g. {report:type} - {field:Client Name} - {date:YYYY-MM-DD}) still visually wrap without expanding into an unbounded textarea, while hitting Enter triggers instant submission.
  3. Pasting Protection: StringUtils.lineBreaksToSpaces guarantees that multiline text copied from external editors is sanitized into a single-line string.

What alternative solutions did you explore? (Optional)

  • Completely removing autoGrowSingleLine and using a static single-line input: Rejected. Workspace default report titles frequently contain multiple formula tokens ({workspace:name}, {report:submitter}, {date:YYYY-MM}), which quickly exceed the single-line width. autoGrowSingleLine provides the ideal balance between single-line semantics and visual formula readability.

What automated tests can you add to prevent this from re-occurring?

In tests/unit/ReportsDefaultTitleTest.tsx:

  • Render ReportsDefaultTitle.
  • Submit the form with multiline input: "Report Title\nWith\nNewlines".
  • Assert setPolicyDefaultReportTitle is called with "Report Title With Newlines".
  • Verify pressing Enter triggers form submission.

camesenin avatar Oct 22 '26 15:10 camesenin

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 22 '26 15:10 melvin-bot[bot]

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 22 '26 15:10 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/hamzakhanbuic

Proposal

Please re-state the problem that we are trying to solve in this issue.

In Workspace settings > Reports > Default report title, the title input field accepts multiline text. Pressing Enter inserts a newline instead of submitting the form, and line breaks are saved into the default report title. The field should only accept single-line input.


What is the root cause of that problem?

  1. Incorrect Multiline Configuration on InputWrapper (ReportsDefaultTitle.tsx:131–140):

    <InputWrapper
        InputComponent={TextInput}
        role={CONST.ROLE.PRESENTATION}
        inputID={INPUT_IDS.DEFAULT_TITLE}
        defaultValue={customNameDefaultValue}
        label={translate('workspace.reports.customNameInputLabel')}
        aria-label={translate('workspace.reports.customNameInputLabel')}
        maxAutoGrowHeight={variables.textInputAutoGrowMaxHeight}
        spellCheck={false}
        autoFocus
        autoGrowHeight
        ref={(el: BaseTextInputRef | null): void => {
            if (!isInputInitializedRef.current) {
                updateMultilineInputRange(el);
            }
            isInputInitializedRef.current = true;
        }}
    />
    

    The field sets autoGrowHeight, which configures TextInput as a multiline textarea (multiline={true}). Per InputWrapper.tsx:48–50, true multiline inputs reserve the Enter key for inserting newlines rather than submitting the form.

  2. Missing Normalization for Pasted Line Breaks (ReportsDefaultTitle.tsx:83–86): submitForm passes values.defaultTitle directly to setPolicyDefaultReportTitle without sanitizing line breaks, allowing pasted multiline text to be persisted to Onyx and backend storage.


What changes do you think we should make in order to solve the problem?

Adopt the exact established pattern from src/pages/EditReportFieldText.tsx:

1. In src/pages/workspace/reports/ReportsDefaultTitle.tsx:

  1. Replace autoGrowHeight and maxAutoGrowHeight with autoGrowSingleLine. As documented in InputWrapper.tsx:48–50:

    "autoGrowSingleLine inputs only render as multi-line so their value can wrap - a new line is never a valid value there, so nothing has to be reserved for inserting one and the return key always submits." This preserves visual wrapping for long title formulas/variables while enforcing single-line Enter-to-submit semantics.

  2. In validateCustomName and submitForm, normalize the title with StringUtils.lineBreaksToSpaces before validation and persistence so that pasted text containing line breaks is collapsed into spaces.
  3. Apply StringUtils.lineBreaksToSpaces to customNameDefaultValue to normalize any legacy values saved with line breaks.
  4. Remove updateMultilineInputRange and isInputInitializedRef since multiline selection range manipulation is no longer required for single-line inputs.
--- a/src/pages/workspace/reports/ReportsDefaultTitle.tsx
+++ b/src/pages/workspace/reports/ReportsDefaultTitle.tsx
@@ -21,7 +21,7 @@ import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavig
 import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
 import {getTitleFieldWithFallback} from '@libs/ReportUtils';
-import updateMultilineInputRange from '@libs/updateMultilineInputRange';
+import StringUtils from '@libs/StringUtils';
 
 import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
 
-import variables from '@styles/variables';
-
 import {clearPolicyTitleFieldError, setPolicyDefaultReportTitle} from '@userActions/Policy/Policy';
 
 import CONST from '@src/CONST';
@@ -46,7 +44,6 @@ function ReportsDefaultTitlePage({route}: RulesCustomNamePageProps) {
     const {translate} = useLocalize();
     const styles = useThemeStyles();
     const getReviewWorkspaceSettingsTaskCompletion = useReviewWorkspaceSettingsTaskCompletion();
-    const isInputInitializedRef = useRef(false);
     const RULE_EXAMPLE_BULLET_POINTS = [
         translate('workspace.reports.customNameEmailPhoneExample'),
         translate('workspace.reports.customNameStartDateExample'),
@@ -56,15 +53,16 @@ function ReportsDefaultTitlePage({route}: RulesCustomNamePageProps) {
     ] as const satisfies string[];
 
     const titleField = getTitleFieldWithFallback(policy);
-    const customNameDefaultValue = Str.htmlDecode(titleField?.defaultValue ?? '');
+    const customNameDefaultValue = StringUtils.lineBreaksToSpaces(Str.htmlDecode(titleField?.defaultValue ?? ''));
 
     const validateCustomName = useCallback(
         ({defaultTitle}: FormOnyxValues<typeof ONYXKEYS.FORMS.REPORTS_DEFAULT_TITLE_MODAL_FORM>) => {
             const errors: FormInputErrors<typeof ONYXKEYS.FORMS.REPORTS_DEFAULT_TITLE_MODAL_FORM> = {};
-            if (!defaultTitle) {
+            const sanitizedTitle = StringUtils.lineBreaksToSpaces(defaultTitle).trim();
+            if (!sanitizedTitle) {
                 errors[INPUT_IDS.DEFAULT_TITLE] = translate('common.error.fieldRequired');
-            } else if (defaultTitle.length > CONST.REPORT_TITLE_FORMULA_LIMIT) {
-                errors[INPUT_IDS.DEFAULT_TITLE] = translate('common.error.characterLimitExceedCounter', defaultTitle.length, CONST.REPORT_TITLE_FORMULA_LIMIT);
+            } else if (sanitizedTitle.length > CONST.REPORT_TITLE_FORMULA_LIMIT) {
+                errors[INPUT_IDS.DEFAULT_TITLE] = translate('common.error.characterLimitExceedCounter', sanitizedTitle.length, CONST.REPORT_TITLE_FORMULA_LIMIT);
             }
             return errors;
         },
@@ -81,7 +79,8 @@ function ReportsDefaultTitlePage({route}: RulesCustomNamePageProps) {
     });
 
     const submitForm = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.REPORTS_DEFAULT_TITLE_MODAL_FORM>) => {
-        setPolicyDefaultReportTitle(policyID, values.defaultTitle, policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE], getReviewWorkspaceSettingsTaskCompletion());
+        const sanitizedTitle = StringUtils.lineBreaksToSpaces(values.defaultTitle).trim();
+        setPolicyDefaultReportTitle(policyID, sanitizedTitle, policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE], getReviewWorkspaceSettingsTaskCompletion());
         Navigation.goBack();
     };
 
@@ -128,16 +127,9 @@ function ReportsDefaultTitlePage({route}: RulesCustomNamePageProps) {
                             defaultValue={customNameDefaultValue}
                             label={translate('workspace.reports.customNameInputLabel')}
                             aria-label={translate('workspace.reports.customNameInputLabel')}
-                            maxAutoGrowHeight={variables.textInputAutoGrowMaxHeight}
                             spellCheck={false}
                             autoFocus
-                            autoGrowHeight
-                            ref={(el: BaseTextInputRef | null): void => {
-                                if (!isInputInitializedRef.current) {
-                                    updateMultilineInputRange(el);
-                                }
-                                isInputInitializedRef.current = true;
-                            }}
+                            autoGrowSingleLine
                         />
                     </OfflineWithFeedback>

Key Advantages:

  1. Preserves Visual Text Wrapping Without Newlines: Unlike removing auto-grow entirely (which causes long templates like {report:type} - {user:email} - {date:startDate} to scroll horizontally off-screen), autoGrowSingleLine allows the text to wrap cleanly within the input view while retaining single-line submit behavior.
  2. Defensive Normalization: Pasted text containing newlines is automatically converted to spaces, matching EditReportFieldText.tsx.
  3. Clean Codebase: Removes unused refs and imports (updateMultilineInputRange, variables).

What alternative solutions did you explore? (Optional)

  1. Disabling auto-grow entirely (removing autoGrowHeight without replacing with autoGrowSingleLine):
    • Rejected because default report title templates often contain long variable formulas. Forcing a standard rigid single-line input causes templates to truncate and scroll sideways, degrading the editing experience.
  2. Blocking submission with an error when newlines are present:
    • Rejected. Normalizing newlines into spaces on paste is standard across Expensify and avoids user frustration when copying templates from emails or external docs.

What specific scenarios should we cover in automated tests to prevent reintroduction of this issue in the future?

In tests/unit/ReportsDefaultTitlePageTest.tsx:

  1. Enter Key Submission:
    • Verify that InputWrapper renders with autoGrowSingleLine={true} and pressing Enter triggers submitForm.
  2. Pasted Newline Sanitization:
    • Submit a title containing multiple newlines (e.g. "Monthly\nReport\nExpenses").
    • Assert that setPolicyDefaultReportTitle is called with "Monthly Report Expenses".
  3. Empty String After Trim:
    • Submit a string containing only newlines and whitespace (e.g. "\n \n").
    • Assert that validateCustomName produces fieldRequired error.

HamzaKhanBUIC avatar Oct 22 '26 17:10 HamzaKhanBUIC

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 22 '26 17:10 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~015055563b6090af39

HamzaKhanBUIC avatar Oct 22 '26 18:10 HamzaKhanBUIC

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 22 '26 18:10 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

In Workspace settings > Reports > Default report title, the input field accepts multiline text. Pressing Enter or pasting multiline text inserts line breaks into the report title template, but default report title should only accept a single line.

What is the root cause of that problem?

In src/pages/workspace/reports/ReportsDefaultTitle.tsx, InputWrapper is configured with autoGrowHeight, maxAutoGrowHeight={variables.textInputAutoGrowMaxHeight}, and calls updateMultilineInputRange(el) in its ref callback. Because autoGrowHeight is set to true on the underlying TextInput, it renders as a multiline input that dynamically expands and allows users to enter newlines. Furthermore, there is no validation in validateCustomName preventing line breaks.

What changes do you think we should make in order to solve the problem?

  1. In src/pages/workspace/reports/ReportsDefaultTitle.tsx:
    • Remove autoGrowHeight, maxAutoGrowHeight={variables.textInputAutoGrowMaxHeight}, and the multiline ref callback from InputWrapper.
    • Remove unused imports updateMultilineInputRange, variables, and isInputInitializedRef.
  2. To prevent users from pasting multiline text:
    • In validateCustomName, add validation to reject inputs containing newline characters (\n or \r), or sanitize the input in submitForm by stripping/replacing line breaks with spaces.
    • Explicitly pass multiline={false} to InputWrapper.

What alternative solutions did you explore? (Optional)

N/A

fangjian-bit avatar Oct 23 '26 07:10 fangjian-bit

📣 @fangjian-bit! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Oct 23 '26 07:10 melvin-bot[bot]

Accepting Melvin's proposal. Root cause is correct, autoGrowHeight makes the default report title a multiline input, so Enter inserts a line break and submitForm saves that value unchanged. autoGrowSingleLine is the right fix: long formulas still wrap, and Enter submits the form. Flatten line breaks with StringUtils.lineBreaksToSpaces before validating and saving, as EditReportFieldText does.

Please include these details in the implementation:

  • Validate and save StringUtils.lineBreaksToSpaces(value).trim(). Use that string for both the required check and the REPORT_TITLE_FORMULA_LIMIT check. A newline-only value becomes spaces, so the current if (!defaultTitle) check would accept it.
  • Apply the same flattening to customNameDefaultValue, after Str.htmlDecode, so a title already saved with line breaks opens as one line.
  • Keep the existing autoFocus prop and updateMultilineInputRange ref. autoGrowSingleLine still renders a multiline input, and that ref places the caret at the end of an existing formula. maxAutoGrowHeight can be removed; autoGrowSingleLine already defaults it.

🎀👀🎀

rojiphil avatar Oct 23 '26 18:10 rojiphil

Triggered auto assignment to @NicolasBonet, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Oct 23 '26 18:10 melvin-bot[bot]

Contributor details

fangjian-bit avatar Oct 26 '26 01:10 fangjian-bit

⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.

melvin-bot[bot] avatar Oct 26 '26 01:10 melvin-bot[bot]

Contributor details

fangjian-bit avatar Oct 26 '26 01:10 fangjian-bit

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 26 '26 01:10 melvin-bot[bot]

I agree @rojiphil

NicolasBonet avatar Oct 26 '26 13:10 NicolasBonet