Skip to content

Exclude built-in title field from duplicate workspace report fields count#90340

Draft
MelvinBot wants to merge 5 commits into
mainfrom
claude-excludeTitleFieldFromDuplicateWSCount
Draft

Exclude built-in title field from duplicate workspace report fields count#90340
MelvinBot wants to merge 5 commits into
mainfrom
claude-excludeTitleFieldFromDuplicateWSCount

Conversation

@MelvinBot
Copy link
Copy Markdown
Contributor

@MelvinBot MelvinBot commented May 12, 2026

Explanation of Change

The report fields count on the duplicate workspace confirmation page (WorkspaceDuplicateSelectFeaturesForm.tsx) included the built-in text_title field, which is always present in policy.fieldList and has no pendingAction. This caused the count to be inflated by 1 — showing 1 even when all custom report fields were pending deletion offline.

This adds a fieldID !== CONST.REPORT_FIELD_TITLE_FIELD_ID filter to exclude the built-in title field, matching the existing behavior in WorkspaceReportsPage.tsx which already filters it out.

Fixed Issues

$ #89716
PROPOSAL: #89716 (comment)

Tests

  1. Disable Report fields in a workspace (Workspace > Reports).
  2. Duplicate the workspace.
  3. Verify that Report fields is disabled in the duplicated workspace.
  4. Enable Report fields in the workspace (Workspace > Reports).
  5. Duplicate the workspace.
  6. Verify that Report fields is enabled in the duplicated workspace.

Offline tests

  1. Disable Report fields in a workspace (Workspace > Reports).
  2. Duplicate the workspace.
  3. Verify that Report fields is disabled in the duplicated workspace.
  4. Enable Report fields in the workspace (Workspace > Reports).
  5. Duplicate the workspace.
  6. Verify that Report fields is enabled in the duplicated workspace.

QA Steps

  1. Disable Report fields in a workspace (Workspace > Reports).
  2. Duplicate the workspace.
  3. Verify that Report fields is disabled in the duplicated workspace.
  4. Enable Report fields in the workspace (Workspace > Reports).
  5. Duplicate the workspace.
  6. Verify that Report fields is enabled in the duplicated workspace.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

… workspace confirmation page

The report fields count on the duplicate workspace confirmation page includes the
built-in text_title field, which should be excluded (matching WorkspaceReportsPage
behavior). This causes the count to show 1 even when all custom report fields have
been pending-deleted offline.

Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/libs/actions/Policy/Policy.ts 69.40% <ø> (-0.02%) ⬇️
... and 1317 files with indirect coverage changes

Copy link
Copy Markdown
Contributor

@sobitneupane sobitneupane left a comment

Choose a reason for hiding this comment

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

Screenshots/Videos

MacOS: Chrome / Safari
Screen.Recording.2026-05-15.at.21.03.21.mov

@sobitneupane
Copy link
Copy Markdown
Contributor

@MelvinBot When I disable the Report fields in offline and then duplicate the workspace, the Report fields become enabled in the duplicated workspace. Could you please ensure that the Report fields remain disabled in the duplicated workspace as well?

…plicate form

When report fields are disabled offline, the toggle should not appear
in the duplication features form, matching the pattern used by
distanceRates and invoices.

Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed — the duplication form now also checks policy?.areReportFieldsEnabled before showing the "Reports" toggle, matching the pattern already used by distance rates (areDistanceRatesEnabled) and invoices (areInvoicesEnabled).

When report fields are disabled offline, the toggle won't appear in the feature selection list, so parts.reports will be false and the duplicated workspace will correctly have report fields disabled.

@sobitneupane
Copy link
Copy Markdown
Contributor

@MelvinBot This will block users from copying Reports entirely. Should we instead set areReportFieldsEnabled to sourcePolicy?.areReportFieldsEnabled in buildOptimisticDuplicatePolicy when isReportsFeatureSelected is true?

areReportFieldsEnabled: isReportsFeatureSelected,

Instead of hiding the Reports toggle when areReportFieldsEnabled is
false (which blocks copying Reports entirely), preserve the source
policy's areReportFieldsEnabled value in buildOptimisticDuplicatePolicy.

Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Good call — reverted the form change and instead updated buildOptimisticDuplicatePolicy to preserve the source policy's areReportFieldsEnabled value when reports are selected, rather than always setting it to true.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

All CI checks are passing. The only "failing" check is PR Author Checklist, which is an informational reminder to complete the checklist — not a code issue. All other checks (ESLint, Prettier, typecheck, all 8 test jobs, builds, spellcheck, storybook, CLA, etc.) pass successfully.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The perf-tests failure is unrelated to this PR's changes.

Failure: [ReportActionCompose] should render Composer with text input interactions — render count exceeded allowed deviation by 1.

Why it's unrelated: This PR only touches Policy.ts and WorkspaceDuplicateSelectFeaturesForm.tsx, which have no connection to ReportActionCompose. The same perf-tests check is also failing on multiple other unrelated branches today, confirming this is a pre-existing/flaky issue.

The only other failing check is the PR Author Checklist, which is informational. All code-related checks (ESLint, Prettier, typecheck, all 8 test jobs, builds) pass.

@sobitneupane
Copy link
Copy Markdown
Contributor

Screenshot 2026-05-17 at 19 07 51
Sample fieldList
{
    "expensify_field_id_REPORT_FIELD_1": {
        "fieldID": "field_id_REPORT_FIELD_1",
        "name": "report_field_1",
        ...
    },
    "expensify_field_id_REPORT_FIELD_2": {
        "fieldID": "field_id_REPORT_FIELD_2",
        "name": "report_field_2",
        ...
    },
    "text_title": {
        "defaultValue": "{report:total} | {report:total:usd} | {report:total:NPR} | 102",
        "fieldID": "text_title",
        "name": "title",
        ...
    }
}

@JS00001

If we ignore text_title, the report title won't be passed when duplicating the workspace (if there are no other report fields).
If we include it, it inflates the report field count by 1, even though it's not really a report field.

One possible approach it to treat text_title separately in the UI and show something like:
"Report title, 2 report fields" in the subtext

What do you think?
Screenshot 2026-05-17 at 19 28 14

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented May 18, 2026

One possible approach it to treat text_title separately in the UI and show something like:
"Report title, 2 report fields" in the subtext

Can we just make it count the report fields & exclude the title? Since thats not a field?

areRulesEnabled: isRulesFeatureSelected,
areWorkflowsEnabled: isWorkflowsFeatureSelected,
areReportFieldsEnabled: isReportsFeatureSelected,
areReportFieldsEnabled: isReportsFeatureSelected ? sourcePolicy?.areReportFieldsEnabled : false,
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 is this needed?

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.

The duplicated workspace will have report fields enabled regardless of the original workspace state if we don’t include this change.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The perf-tests failure is unrelated to this PR's changes.

Failing test: [ReportActionCompose] should render Composer with text input interactions — render count exceeded allowed deviation by 1.

Why it's unrelated: This PR only modifies Policy.ts and WorkspaceDuplicateSelectFeaturesForm.tsx (workspace duplication logic). The failing test is for ReportActionCompose, a completely different component with no connection to the changed files.

Evidence: The same Reassure perf test is failing across many unrelated PRs right now (e.g., branches fix/89545, use-shared-country-zip-regex, 89302-import-spreadsheet-modal-refactor, and others). This is a known flaky/pre-existing failure in the test suite.

No code fix is needed on this PR for this check.

@sobitneupane
Copy link
Copy Markdown
Contributor

sobitneupane commented May 19, 2026

Can we just make it count the report fields & exclude the title? Since thats not a field?

@JS00001 We can do that, but if we go that route, the report title won’t be included when duplicating the workspace in cases where there are no other report fields. However, if there is at least one report field, the report title will be included, which leads to inconsistent behavior.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The perf-tests failure is unrelated to this PR.

Failing test: [ReportActionCompose] should render Composer with text input interactions — render count exceeded allowed deviation by 1.

Why it's unrelated: This PR only changes Policy.ts and WorkspaceDuplicateSelectFeaturesForm.tsx, neither of which is connected to ReportActionCompose. This is a pre-existing flaky perf regression.

The other two failing checks (PR Author Checklist and PR Reviewer Checklist) are checklist validations, not code issues.

@sobitneupane
Copy link
Copy Markdown
Contributor

@JS00001 Just a gentle bump on these comments when you get a chance: #90340 (comment) and #90340 (comment). Thanks!

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented May 22, 2026

We can do that, but if we go that route, the report title won’t be included when duplicating the workspace in cases where there are no other report fields. However, if there is at least one report field, the report title will be included, which leads to inconsistent behavior.

Can you explain this more please?

@sobitneupane
Copy link
Copy Markdown
Contributor

Screenshot 2026-05-17 at 19 07 51
Sample fieldList
{
    "expensify_field_id_REPORT_FIELD_1": {
        "fieldID": "field_id_REPORT_FIELD_1",
        "name": "report_field_1",
        ...
    },
    "expensify_field_id_REPORT_FIELD_2": {
        "fieldID": "field_id_REPORT_FIELD_2",
        "name": "report_field_2",
        ...
    },
    "text_title": {
        "defaultValue": "{report:total} | {report:total:usd} | {report:total:NPR} | 102",
        "fieldID": "text_title",
        "name": "title",
        ...
    }
}

When we ignore the text_title field from the fieldList, there are still two report fields present (in sample fieldList above). As a result, during workspace duplication, the user sees the option to select the Reports feature (as shown in the screenshot below), and all three items(including text_title) in the sample fieldList are passed to the duplicated workspace.

However, if text_title is the only field (i.e., the user hasn’t added any report fields), the Reports feature is not shown on the "Select features to copy" screen and the report configuration is not passed to the duplicated workspace.

Screenshot 2026-05-17 at 19 28 14

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented May 25, 2026

@sobitneupane lets include it as a report field then

@sobitneupane
Copy link
Copy Markdown
Contributor

@JS00001 This is the existing behavior. For report title and 2 report fields, we currently display "3 report fields".

The separate issue we are trying to address here is that a duplicated workspace has report fields enabled regardless of the original workspace's state However, this wasn't reported in the original issue.

Should we proceed with only this latter change?

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented May 26, 2026

Yeah lets ignore the report title issues then

Comment on lines +49 to +52
const reportFields =
Object.values(getReportFieldsByPolicyID(policyID) ?? {}).filter(
(field) => field.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && field.fieldID !== CONST.REPORT_FIELD_TITLE_FIELD_ID,
).length ?? 0;
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.

@MelvinBot Let's revert the change made in WorkspaceDuplicateSelectFeaturesForm. We decided to include CONST.REPORT_FIELD_TITLE_FIELD_ID in the reportFields.

Per reviewer feedback, the built-in title field should be included
in the reportFields count on the duplicate workspace confirmation page.

Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Reverted the REPORT_FIELD_TITLE_FIELD_ID filter in WorkspaceDuplicateSelectFeaturesFormreportFields now includes the built-in title field again.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The checks on this PR are not failing — the latest run (triggered a few minutes ago) is still in progress with all checks queued or running.

The only historical failures on this branch are PR Author Checklist and PR Reviewer Checklist, which track manual checkbox completion in the PR description and are not fixable via code changes.

If checks fail once the current run completes, feel free to tag me again and I'll investigate.

@sobitneupane
Copy link
Copy Markdown
Contributor

@MelvinBot Please merge main

…xcludeTitleFieldFromDuplicateWSCount

Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Merged main into this branch.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The ESLint failure is unrelated to this PR.

Error: 'getKeywordQueryWithCurrentSearchContext' is defined but never used in tests/unit/Search/SearchQueryUtilsTest.ts:20

Why it's unrelated: This PR only changes src/libs/actions/Policy/Policy.ts. The lint error is in a Search test file that imports getKeywordQueryWithCurrentSearchContext but never uses it — this same issue exists on main.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

⚠️ MelvinBot CI Fix Loop Detected

MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR.

Next steps: A human should review the recent commits and resolve the conflicting CI errors manually.

@sobitneupane
Copy link
Copy Markdown
Contributor

@MelvinBot Please complete the author checklist with all items checked (no N/A). I have manually verified that all the items can be checked.

Also, update the Tests, Offline tests and QA steps with the following:

  1. Disable Report fields in a workspace (Workspace > Reports).
  2. Duplicate the workspace.
  3. Verify that Report fields is disabled in the duplicated workspace.
  4. Enable Report fields in the workspace (Workspace > Reports).
  5. Duplicate the workspace.
  6. Verify that Report fields is enabled in the duplicated workspace.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

No code fix needed — the test (job 3) failure is a CI infrastructure issue, not a code problem. GitHub Actions failed to download the useblacksmith/checkout action after 3 retries:

Error while copying content to a stream.
Failed to download archive '...useblacksmith/checkout...' after 3 attempts.

The other failing check (PR Author Checklist) is the manual checkbox check.

To resolve: Re-run the failed job, or push an empty change to trigger a new CI run. The remaining test jobs are still in progress and may pass.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

Updated the PR body:

  • All author checklist items are now checked
  • Tests, Offline tests, and QA steps updated with the report fields enable/disable duplication steps

@sobitneupane
Copy link
Copy Markdown
Contributor

@JS00001 For the issue I mentioned above ("a duplicated workspace has report fields enabled regardless of the original workspace's state"), the backend currently always set areReportFieldsEnabled to false during duplication, regardless of the original workspace's state. So, we also need to make changes in the backend.

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented May 27, 2026

the backend currently always set areReportFieldsEnabled to false during duplication, regardless of the original workspace's state. So, we also need to make changes in the backend.

So we want the report fields to be enabled or disabled based on the previous workspace? OR based on the user selection?

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented May 27, 2026

PR open for this here: https://github.com/Expensify/Web-Expensify/pull/53201/

@sobitneupane
Copy link
Copy Markdown
Contributor

So we want the report fields to be enabled or disabled based on the previous workspace? OR based on the user selection?

If the user has selected "Reports" feature in "Select features to copy" (isReportsFeatureSelected is true), then the report fields should be enabled or disabled based on the previous workspace. If isReportsFeatureSelected is false, report fields should remain disabled.

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented May 27, 2026

Agreed, sounds good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants