Skip to content

[Due for payment 2026-05-11] [$250] Categories - Re-imported categories become disabled after adding new category #87033

Closed

Description

@vincdargento

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.52-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #81548
Email or phone of affected tester (no customers): testpayment935@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Windows 11 pro /Chrome
App Component: Workspace Settings

Action Performed:

  1. Navigate to staging.new.expensify.com
  2. Log in as a workspace admin on staging.
  3. Navigate to Workspace Settings → Categories.
  4. Export the categories CSV.
  5. Modify the CSV by:
  6. Adding at least one new category
  7. Re-import the CSV via More → Import spreadsheet.

Expected Result:

The enabled category should remain enabled after importing new category

Actual Result:

The all category become disabled
The enabled category CSV changed the enabled input to a capital letter

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022039844386983496376
  • Upwork Job ID: 2039844386983496376
  • Last Price Increase: 2026-04-09

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 2, 2026
  2. MelvinBot commented on Apr 2, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The CSV import logic uses a case-sensitive comparison (=== 'true') when parsing the "enabled" column. When the server-side ExportCategoriesCSV command generates the CSV, it writes the enabled value using non-lowercase casing (e.g., TRUE or True). On re-import, the strict lowercase check at ImportedCategoriesPage.tsx:108 fails for every category, causing them all to be set to enabled: false.

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

    Make the enabled comparison case-insensitive by applying .toLowerCase() before comparing:

    In ImportedCategoriesPage.tsx:108, change the enabled parsing from === 'true' to ?.toLowerCase() === 'true'.

    The same fix should be applied to ImportedTagsPage.tsx:108, which has the identical case-sensitive comparison for tags.

    Investigation details

    Data flow:

    1. User exports categories via downloadCategoriesCSV() → server generates CSV with enabled values in non-lowercase casing
    2. User edits CSV, re-imports via ImportSpreadsheet component
    3. ImportSpreadsheet.tsx reads CSV with XLSX.read() using raw: true, preserving original string casing
    4. Cell values pass through String(cell) — no case normalization occurs
    5. ImportedCategoriesPage.tsx:108 compares with strict === 'true' — fails for TRUE/True
    6. All categories sent to server with enabled: false

    Why raw: true matters: The XLSX library is configured with raw: true at ImportSpreadsheet.tsx:112, which preserves original string values from the CSV without any type coercion or normalization.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 2, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 2, 2026
  5. melvin-bot commented on Apr 2, 2026

    @melvin-bot

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

  6. changed the title [-]Categories - Re-imported categories become disabled after adding new category[/-] [+][$250] Categories - Re-imported categories become disabled after adding new category[/+] on Apr 2, 2026
  7. melvin-bot commented on Apr 2, 2026

    @melvin-bot
  8. trasnake87 commented on Apr 2, 2026

    @trasnake87
    Contributor

    Proposal

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

    When a user exports their workspace categories as CSV and re-imports it (with or without new categories added), all previously enabled categories become disabled because the boolean "enabled" values from the CSV are not normalized during data ingestion.

    What is the root cause of that problem?

    The root cause is in src/libs/actions/ImportSpreadsheet.ts#L34. When setSpreadsheetData transposes and stores the CSV data, it converts every cell to a string via String(row.at(colIndex) ?? '') without normalizing boolean-like values. The backend exports enabled values as "TRUE" or "True", and these are stored verbatim in the Onyx spreadsheet data. Downstream consumers then compare against the lowercase string 'true' and the match fails, causing all categories to be marked as disabled.

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

    We should normalize boolean-like string values to lowercase at the data ingestion point in setSpreadsheetData. This fixes the issue for all import flows (categories and tags) in a single location.

    In src/libs/actions/ImportSpreadsheet.ts, change line 34 from:

    const transposedData: string[][] = firstRow.map((_, colIndex) => data.map((row) => String(row.at(colIndex) ?? '')));

    to:

    const transposedData: string[][] = firstRow.map((_, colIndex) =>
        data.map((row) => {
            const val = String(row.at(colIndex) ?? '');
            const lower = val.toLowerCase();
            if (lower === 'true' || lower === 'false') {
                return lower;
            }
            return val;
        }),
    );

    This normalizes any cell containing a case-variant of "true" or "false" to lowercase at the point where spreadsheet data is stored, so all downstream comparisons (=== 'true') work correctly regardless of how the backend serialized the boolean values.

  9. trasnake87 commented on Apr 2, 2026

    @trasnake87
    Contributor

    Contributor details
    Your Expensify account email: trasnake87@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~010f770315ab181656

  10. melvin-bot commented on Apr 2, 2026

    @melvin-bot

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

  11. wildan-m commented on Apr 2, 2026

    @wildan-m
    Contributor

    Proposal

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

    When a workspace admin exports categories to CSV, modifies it (e.g. adds a new category), and re-imports the CSV, all previously enabled categories become disabled.

    What is the root cause of that problem?

    The CSV import logic in ImportedCategoriesPage uses a strict case-sensitive comparison === 'true' when parsing the enabled column from the imported spreadsheet:

    enabled: categoriesEnabledColumn !== -1 ? categoriesEnabled?.[containsHeader ? index + 1 : index] === 'true' : true,

    The server-side ExportCategoriesCSV command generates the CSV with the enabled value in non-lowercase casing (e.g. TRUE or True). The ImportSpreadsheet component reads the CSV using XLSX.read() with raw: true, which preserves the original string casing without normalization:

    .then((text) => XLSX.read(text, {type: 'string', raw: true}));

    Cell values then pass through String(cell) which also does not normalize casing. So "TRUE" === 'true' evaluates to false, and every category gets sent to the server with enabled: false.

    The same bug exists in ImportedTagsPage at the identical line:

    enabled: tagsEnabledColumn !== -1 ? tagsEnabled?.[containsHeader ? index + 1 : index] === 'true' : true,

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

    Make the enabled comparison case-insensitive by normalizing the value to lowercase before comparing. In both ImportedCategoriesPage.tsx (line 108) and ImportedTagsPage.tsx (line 108), change === 'true' to ?.toLowerCase() === 'true'.

    This handles all casing variants (TRUE, True, true) from server-generated CSV exports. The optional chaining (?.) is needed because the value can be undefined if the spreadsheet row is shorter than expected.

    Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/87033-fix-csv-import-enabled-casing?expand=1

    What alternative solutions did you explore? (Optional)

    An alternative would be to normalize boolean-like cell values at the ImportSpreadsheet component level (in the cell processing step at lines 125-136) so all downstream import pages receive consistent lowercase strings. However, this is more invasive — it changes shared infrastructure used by all import flows (categories, tags, members) and could have unintended side effects on non-boolean columns. Fixing at the point of comparison is safer and more targeted.

  12. wildan-m commented on Apr 2, 2026

    @wildan-m
    Contributor

    Proposal

    Updated

    Added compare branch with implementation.

  13. 41 remaining items

  14. melvin-bot commented on May 10, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. melvin-bot commented on May 11, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2039844386983496376/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  16. mallenexpensify commented on May 12, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @sobitneupane due $250 via NewDot

    @sobitneupane plz complete the BZ checklist and tag me in a post once you have. Thx

  17. sobitneupane commented on May 14, 2026

    @sobitneupane
    Contributor

    Regression Test Proposal

    Test:

    1. Log in as a workspace admin
    2. Navigate to Workspace Settings → Categories
    3. Export the categories CSV
    4. Note that the CSV contains TRUE (or True) for enabled categories
    5. Add a new category row to the CSV
    6. Re-import the CSV via More → Import spreadsheet
    7. Verify that previously enabled categories remain enabled after import
    8. Repeat steps 3-7 for Tags (Workspace Settings → Tags)

    Do we agree 👍 or 👎

  18. sobitneupane commented on May 14, 2026

    @sobitneupane
    Contributor

    BugZero Checklist:

    Zapier Logs Run ID: 00040eee-dc62-a608-3710-c294877592e4
  19. sobitneupane commented on May 14, 2026

    @sobitneupane
    Contributor

    @mallenexpensify

    • BugZero Checklist
  20. melvin-bot commented on May 15, 2026

    @melvin-bot

    @mallenexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

  21. JmillsExpensify commented on May 24, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @sobitneupane

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions