Skip to content

Add receipt requirement columns to category spreadsheet import#88962

Draft
MelvinBot wants to merge 2 commits intomainfrom
claude-addReceiptColumnsToSpreadsheetImport
Draft

Add receipt requirement columns to category spreadsheet import#88962
MelvinBot wants to merge 2 commits intomainfrom
claude-addReceiptColumnsToSpreadsheetImport

Conversation

@MelvinBot
Copy link
Copy Markdown
Contributor

Explanation of Change

Adds support for two new optional columns in the category spreadsheet import for Control policies: Require receipts over (maxAmountNoReceipt) and Require itemized receipts over (maxAmountNoItemizedReceipt).

When admins import categories via CSV, they can now include these columns with values matching the OD import logic:

  • default → reset to policy default (null)
  • required / always_required → always require (0)
  • not_required → never require (DISABLED_MAX_EXPENSE_VALUE)
  • A numeric threshold (e.g. 2500) → require over that amount

The import applies the same normalization as the manual UI:

  • If receipts = not_required, itemized receipts are forced to not_required
  • If itemized receipts = always_required (0), receipts are forced to always_required (0)

If neither column is mapped, existing receipt settings are preserved (no change to current behavior).

Fixed Issues

$ #86106

Tests

// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
// Please describe what tests you performed that validates your changed worked.

  • Verify that no errors appear in the JS console

Offline tests

// TODO

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

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
    • 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

Screenshots/Videos

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

Support "Require receipts over" and "Require itemized receipts over" columns
in the category CSV import flow for Control policies. Values are parsed using
the same logic as OD: default, required/always_required, not_required, or a
numeric threshold. Normalization ensures consistent states (e.g. receipts
not_required forces itemized receipts to not_required).

Co-authored-by: Daniel Gale-Rosen <[email protected]>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 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/CONST/index.ts 92.30% <ø> (ø)
src/libs/actions/Policy/Category.ts 52.95% <28.57%> (-0.38%) ⬇️
src/components/ImportColumn.tsx 0.00% <0.00%> (ø)
...es/workspace/categories/ImportedCategoriesPage.tsx 0.00% <0.00%> (ø)
... and 8 files with indirect coverage changes

@dangrous
Copy link
Copy Markdown
Contributor

@codex review

@dangrous dangrous requested a review from suneox April 29, 2026 15:58
@dangrous
Copy link
Copy Markdown
Contributor

@suneox here's the PR if you want to take a look!

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d101b5354d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +154 to +155
if (normalizedMaxAmountNoItemizedReceipt === 0 && normalizedMaxAmountNoReceipt !== undefined) {
normalizedMaxAmountNoReceipt = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize paired receipt rules when only one CSV column is mapped

The new normalization logic only runs when both parsed values are defined, so imports that map just one of the new columns can leave category rules in a state that diverges from the manual UI behavior. For example, mapping only maxAmountNoItemizedReceipt to always_required (0) will not force maxAmountNoReceipt to 0 because normalizedMaxAmountNoReceipt is undefined; similarly, mapping only maxAmountNoReceipt to not_required will not force itemized to not_required. This means the import path does not consistently apply the intended coupled-rule normalization for existing categories.

Useful? React with 👍 / 👎.

@suneox
Copy link
Copy Markdown
Contributor

suneox commented Apr 30, 2026

@MelvinBot The auto-match logic in findColumnName func at ImportColumn.tsx is missing cases for the new receipt requirement columns.

When users upload a CSV with headers "Receipts Required" or "Itemised Receipt Requirement", these columns are not automatically mapped to their respective attribute
(MAX_AMOUNT_NO_RECEIPT and MAX_AMOUNT_NO_ITEMIZED_RECEIPT) Please add these so they're mapped automatically on CSV upload

Here is the list of columns from the example file:
name,GL Code,Payroll Code,Receipts Required,Comments,Max Expense amount,Comment Hint,Itemised Receipt Requirement,Tax Name

@MelvinBot
Copy link
Copy Markdown
Contributor Author

Good catch — the findColumnName switch statement is indeed missing cases for receiptsrequiredMAX_AMOUNT_NO_RECEIPT and itemisedreceiptrequirementMAX_AMOUNT_NO_ITEMIZED_RECEIPT.

The fix would be adding two new case blocks (around line 143, before the default):

case 'receiptsrequired':
case 'requirereceiptsover':
case 'maxamountnoreceipt':
    attribute = CONST.CSV_IMPORT_COLUMNS.MAX_AMOUNT_NO_RECEIPT;
    break;

case 'itemisedreceiptrequirement':
case 'itemizedreceiptrequirement':
case 'requireitemizedreceiptsover':
case 'maxamountnoitemizedreceipt':
    attribute = CONST.CSV_IMPORT_COLUMNS.MAX_AMOUNT_NO_ITEMIZED_RECEIPT;
    break;

I can only make code changes when directed by the PR author, an assignee, or an existing co-author. To have me implement this, the PR assignee or author should reply with a request tagging me.

@suneox
Copy link
Copy Markdown
Contributor

suneox commented Apr 30, 2026

@dangrous Could you please reassign this pr to me so I can work on it to resolve this issue? I’ll collaborate with Melvin Bot until it’s done and then ping you. Thanks!

@MelvinBot
Copy link
Copy Markdown
Contributor Author

⏱️ Ran out of time before I could finish. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in #melvinbot-ai.

Run details

@dangrous dangrous assigned suneox and unassigned dangrous Apr 30, 2026
@dangrous
Copy link
Copy Markdown
Contributor

all set!

@suneox
Copy link
Copy Markdown
Contributor

suneox commented Apr 30, 2026

@MelvinBot Let resolve the conflicts and update the PR according to this issue

Resolves merge conflict in ImportedCategoriesPage.tsx (kept dataIndex
variable with .trim() from main).

Adds findColumnName cases so CSV headers like "Receipts Required" and
"Itemised Receipt Requirement" are automatically mapped to
MAX_AMOUNT_NO_RECEIPT and MAX_AMOUNT_NO_ITEMIZED_RECEIPT.

Co-authored-by: suneox <[email protected]>
Co-authored-by: Cong Pham <[email protected]>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Resolved the merge conflict and added the auto-match cases for receipt requirement CSV columns.

Changes:

  1. Merge conflict resolved in ImportedCategoriesPage.tsx — kept the dataIndex variable (from this PR) and incorporated the .trim() call added on main.
  2. Added findColumnName cases in ImportColumn.tsx:144-156 so CSV headers like "Receipts Required" and "Itemised Receipt Requirement" are auto-mapped to MAX_AMOUNT_NO_RECEIPT and MAX_AMOUNT_NO_ITEMIZED_RECEIPT.

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