Skip to content

[$175] Dependent Tags only accept one uploaded file in New Expensify, preventing customers from uploading more than 50,000 tag rows #102888

Open

Description

@izarutskaya

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.0-5
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @jalynmsc
Slack conversation (hyperlinked to channel name): #expensify_bugs

Action Performed:

  1. Goes to the workspace in New Expensify.
  2. Goes to the Tags settings for the workspace.
  3. Configures multi-level dependent tags used for management reporting.
  4. Uploads a file containing dependent tag values.
  5. Attempts to upload an additional file to accommodate tag data exceeding the 50,000-tag limit.
  6. New Expensify only accepts one uploaded file, preventing the customer from adding the remaining dependent tag values.

Expected Result:

The customer should be able to upload multiple tag files, allowing them to maintain dependent tag configurations exceeding 50,000 rows, as they were able to do previously.

Actual Result:

New Expensify only accepts one uploaded tag file with a maximum of 50,000 tags. The customer cannot upload a second file, preventing them from maintaining their full dependent tag structure of up to approximately 100,000 rows.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

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

Screenshots/Videos

Recording.4017.mp4

View all open jobs on GitHub

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

Activity

  1. added
    Daily
    Bug
    on Oct 2, 2026
  2. MelvinBot commented on Oct 2, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    New Expensify's multi-level tag import was built to take one file. It sends that file in one request, and the request replaces every existing tag. So a customer can't upload a second file to add to their dependent tags. Each upload overwrites the one before.

    Classic did not append across uploads either. Its import form had two file slots, and both files went up together in one replace upload. The Classic help article says "divide them into two separate files" and also "each time you upload a list of tags, it will override your previous list." New Expensify never had the second slot.

    The App code has no 50,000-row check. That number appears only in the New Expensify help article.

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

    ⚠️ An internal engineer needs to confirm one thing before anyone builds this. The backend must accept about 100k dependent rows in one import request. The App team can't verify this, because the row and size limits are enforced outside the App repo. If the backend rejects that volume, the fix has to start there.

    If the backend accepts it, you can match Classic in the App:

    1. On the multi-level import step, let the user add up to two CSV/TSV files.
    2. Check that both files have the same header row. Show an error if they don't.
    3. Merge the rows on the client, keeping the header once. Send one merged file through the existing ImportMultiLevelTags call (Tag.ts:901-914). The API stays the same.
    4. Update the New Expensify help article to explain the two-file option.

    What alternative solutions did you explore? (Optional)

    • Send several files in one request. This needs a backend change to accept an array of files.
    • Append rows to existing dependent tags. This needs new backend merge logic, because each import currently replaces all tags. The total size limit would still apply.
    Investigation details
    • Flow: WorkspaceTagsPage → Import spreadsheet → ImportTagsOptionsPage (multi-level) → ImportSpreadsheet (one file) → ImportMultiLevelTagsSettingsPage → importMultiLevelTags → API.write('ImportMultiLevelTags', {policyID, isFirstLineHeader, isIndependent, isGLAdjacent, file}).
    • Client checks: the App only checks file type, that the file isn't empty, and that it has at least 2 rows. It has no maximum row count.
    • Errors: if the backend rejects a file, the user sees a generic "Import failed" modal. They never see a message about the limit.
    • History: the params were added in [Multi-tags] Add ability to partially edit and fully import multi-level tags. No multi-file or append option has existed since.
    • Merging dependent files: both files must share the same headers so their rows land in the same tag levels. If the files are split by level instead, the result is duplicate levels. Classic had this bug with two-file uploads.

    Possibly related: [CFI] [$175] Support appending a custom tag list next to accounting-connection tags in NewDot (indirectTagUploads). It adds an append option to the same import, but for whole tag lists rather than rows, so any backend change should be coordinated with it.


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


    view run

  3. added
    External
    on Oct 2, 2026
  4. melvin-bot commented on Oct 2, 2026

    @melvin-bot

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

  5. changed the title [-]Dependent Tags only accept one uploaded file in New Expensify, preventing customers from uploading more than 50,000 tag rows[/-] [+][$175] Dependent Tags only accept one uploaded file in New Expensify, preventing customers from uploading more than 50,000 tag rows[/+] on Oct 2, 2026
  6. melvin-bot commented on Oct 2, 2026

    @melvin-bot
  7. bonnhatnguyen commented on Oct 2, 2026

    @bonnhatnguyen

    Proposal for Issue #102888: [$175] Dependent Tags only accept one uploaded file in New Expensify, preventing customers from uploading more than 50,000 tag rows

    Contributor Details

    • Contributor: @bonnhatnguyen
    • Email: bonnhatnguyen0@gmail.com
    • Upwork: https://www.upwork.com/freelancers/~0139ed4098bdc50182

    Proposal

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

    In New Expensify, importing multi-level (dependent) tags only allows uploading a single file (capped at 50,000 tag rows). In Expensify Classic, customers with large dependent tag structures could upload multiple (two) CSV files to maintain up to ~100,000 tag rows. In New Expensify, uploading a subsequent file completely overwrites the previous tag hierarchy, preventing customers with >50,000 tag rows from maintaining their full tag structure.


    What is the root cause of that problem?

    1. In src/components/ImportSpreadsheet.tsx:293 and src/components/FilePicker/index.tsx:29:
      • The drop zone and file input strictly read files[0], preventing the user from selecting or dragging more than one file.
      • FilePicker does not support the multiple attribute.
    2. In src/libs/actions/Policy/Tag.ts:901-925, importMultiLevelTags calls API.write(WRITE_COMMANDS.IMPORT_MULTI_LEVEL_TAGS, ...), which transmits a single file that replaces the workspace's entire multi-level tag tree.
    3. In Classic, this limitation was handled on the client by permitting a secondary file slot and uploading both sets together. New Expensify lacks multi-file ingestion and client-side merging for spreadsheet imports.

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

    We can solve this seamlessly on the client side without requiring breaking changes to the backend ImportMultiLevelTags API:

    1. Support Multi-File Selection in FilePicker:

    In src/components/FilePicker/index.tsx:

    • Add an optional multiple?: boolean prop and pass it to the hidden <input type="file" />.
    • When multiple is true, pass Array.from(event.target.files) to onSelected.

    2. In ImportSpreadsheet.tsx:

    • Enable multiple={isImportingMultiLevelTags} on FilePicker and DragAndDropConsumer (allowing up to 2 files).
    • When 2 files are provided:
      1. Read both files using FileReader.
      2. Parse both spreadsheets into row arrays using parseSpreadsheet.
      3. Validate header compatibility: Ensure both files have identical header rows / column counts. If headers differ, display a clear validation error modal (translate('spreadsheet.errorMismatchedHeaders')).
      4. Merge row data: Concatenate the data rows of file 2 to file 1 (excluding file 2's duplicate header row).
      5. Combine them into a single merged File / CSV blob and save to ONYXKEYS.IMPORTED_SPREADSHEET.
    • Proceed normally through ImportMultiLevelTagsSettingsPage and importMultiLevelTags, which uploads the unified merged file containing the full set of up to 100,000 tag rows.

    3. Automated Tests:

    • In tests/unit/ImportSpreadsheetTest.tsx:
      • Test uploading 2 CSV files with matching headers: verify that rows are concatenated cleanly with a single header row and saved to Onyx.
      • Test uploading 2 CSV files with mismatched headers: verify that validation error is surfaced and import is blocked.
      • Test single-file upload remains 100% backward compatible for single-level and multi-level tags.

    What alternative solutions did you explore? (Optional)

    • Backend append API (importMultiLevelTagsAppend):
      Requires adding a new backend command or isAppend flag to Web-E and orchestrating cross-repo deployments. Client-side merging is cleaner, immediate, and fully compatible with the existing single-file upload pipeline.
  8. tuananh4865 commented on Oct 3, 2026

    @tuananh4865

    Contributor Details

    • Contributor: @tuananh4865
    • Email: tuananh4865@gmail.com
    • Upwork: https://www.upwork.com/freelancers/~0146a4de0ca9fff602?companyReference=2103308912547901160&mp_source=share

    Proposal

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

    Expensify Classic lets workspaces with more than 50,000 tags split them across two files (docs/articles/expensify-classic/workspaces/Create-tags.md:58). New Expensify documents a single-file limit of 50,000 tags (docs/articles/new-expensify/workspaces/Create-and-manage-expense-tags.md:85) and the import flow accepts only one file. Workspaces above that size can't be imported in full, which is a parity regression from Classic.

    What is the root cause of that problem?

    1. Client reads exactly one file.
      • src/components/FilePicker/index.tsx:29: const file = event.target.files?.[0];
      • src/components/ImportSpreadsheet.tsx:293 (drop handler): const file = e?.dataTransfer?.files[0];
      • The picker and the drop zone are separate code paths, so both need changes.
    2. API contract takes one file. importMultiLevelTags in src/libs/actions/Policy/Tag.ts (~lines 900–930) sends a single file parameter.
    3. Backend behavior is unverified (assumption).
      • I can't confirm from the client code whether ImportMultiLevelTags replaces all tags on each call, or whether it enforces a hard 50k-row cap.
      • Both points decide which solution below is viable (see Backend prerequisite).

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

    Backend prerequisite (blocking)

    An internal engineer must confirm that ImportMultiLevelTags accepts ~100k rows in one file payload without a hard row check, timeout, or memory failure.

    • Yes: use the client-side merge (Option A). No API change.
    • No: add one of the following to ImportMultiLevelTagsParams.ts and Tag.ts. The client UI and validation in Option A still apply, and only the submit step changes.
      • B1: isAppend parameter. The first call sends isAppend: false, the second isAppend: true. This is simpler for the backend, but the client must handle a failure between the two calls.
      • B2: array of files or file2 slot. This matches Classic and is atomic, so a failed import can't leave a half-imported list.

    Option A: merge two files client-side into one File

    1. Selection UI (opt-in, multi-level tags only)

    • Add an opt-in multiple / maxFiles prop to FilePicker (index.tsx:29) and handle dataTransfer.files in ImportSpreadsheet.tsx:293. All other import flows keep files[0].
    • If more than 2 files are selected, show an error and don't proceed.
    • Show the selected file names in selection order.
    • Update Create-and-manage-expense-tags.md:85 to: "A single file can include up to 50,000 tags. If you have more, select two files and they will be combined into one import."

    2. Merge helper: src/libs/mergeSpreadsheetFiles.ts

    The merge works on bytes and validates before merging. Validation applies only to the two-file path, so single-file behavior is unchanged.

    Check Rule Error
    Extension Both files must have the same extension, .csv+.csv or .tsv+.tsv (case-insensitive). .xlsx/.xls are binary and can't be merged. extensionMismatch / unsupportedType
    Empty Either file has 0 bytes (or only a BOM). empty
    Encoding Both files must decode as UTF-8 via TextDecoder('utf-8', {fatal: true}). Explicitly reject files containing NUL bytes (\0) to guard against un-BOMed UTF-16LE/BE and binary inputs, and enforce valid UTF-8 encoding. invalidEncoding
    BOM Strip a leading EF BB BF from each file for header comparison only. The output keeps file 1's bytes as-is. File 2's header (and BOM) is dropped. none
    CSV well-formedness A strict RFC 4180 state machine (below). Rejects unbalanced quotes, a bare " inside an unquoted field, text after a closing quote, and a bare CR. malformedCsv
    Header Byte-exact comparison of the BOM-stripped header rows, with no case folding or trimming. headerMismatch
    • Quoting and newlines:
      • A newline inside a quoted field is data. "" is an escaped quote.
      • The header ends at the first unquoted LF or CRLF.
      • TSV uses the same state machine with a tab delimiter. RFC 4180 doesn't define TSV, so this is an assumption; confirm what the backend parser expects.
    • Newline preservation:
      • Both bodies are copied byte-for-byte, including internal CRLF/LF and trailing whitespace or empty cells.
      • Only if file 1 doesn't end in LF is one separator inserted, using file 1's detected newline (falling back to file 2's, then \n).
    • Header-only files:
      • If file 2 has no body, the result equals file 1.
      • If file 1 is header-only, the result is file 1's header followed by file 2's body.
    type MergeError = 'extensionMismatch' | 'unsupportedType' | 'empty' | 'invalidEncoding' | 'malformedCsv' | 'headerMismatch';
    type MergeResult = {ok: true; file: File} | {ok: false; error: MergeError};
    type Scan = {headerEnd: number; bodyStart: number; newline: '\n' | '\r\n' | null};
    
    const LF = 0x0a;
    const CR = 0x0d;
    const QUOTE = 0x22;
    const COMMA = 0x2c;
    const TAB = 0x09;
    
    const bomLength = (b: Uint8Array) => (b[0] === 0xef && b[1] === 0xbb && b[2] === 0xbf ? 3 : 0);
    
    function isValidUtf8(bytes: Uint8Array): boolean {
        try {
            new TextDecoder('utf-8', {fatal: true}).decode(bytes);
            return true;
        } catch {
            return false;
        }
    }
    
    /** Strict RFC 4180 scan. Returns null if malformed. Records the first unquoted row terminator as the header end. */
    function scanCsv(bytes: Uint8Array, start: number, delimiter: number): Scan | null {
        let state: 'fieldStart' | 'unquoted' | 'quoted' | 'afterQuote' = 'fieldStart';
        let result: Scan | null = null;
        for (let i = start; i < bytes.length; i++) {
            const c = bytes[i];
            if (state === 'quoted') {
                if (c === QUOTE) {
                    state = 'afterQuote';
                }
                continue;
            }
            if (c === QUOTE) {
                if (state === 'afterQuote') {
                    state = 'quoted'; // escaped ""
                } else if (state === 'fieldStart') {
                    state = 'quoted';
                } else {
                    return null; // quote inside an unquoted field
                }
                continue;
            }
            if (c === delimiter) {
                state = 'fieldStart';
                continue;
            }
            if (c === CR || c === LF) {
                const headerEnd = i;
                if (c === CR) {
                    if (bytes[i + 1] !== LF) {
                        return null; // bare CR
                    }
                    i++;
                }
                result ??= {headerEnd, bodyStart: i + 1, newline: c === CR ? '\r\n' : '\n'};
                state = 'fieldStart';
                continue;
            }
            if (state === 'afterQuote') {
                return null; // text after closing quote
            }
            state = 'unquoted';
        }
        if (state === 'quoted') {
            return null; // unbalanced quote
        }
        return result ?? {headerEnd: bytes.length, bodyStart: bytes.length, newline: null};
    }
    
    const getExt = (f: File) => f.name.split('.').pop()?.toLowerCase();
    
    async function mergeSpreadsheetFiles(first: File, second: File): Promise<MergeResult> {
        const ext = getExt(first);
        if (ext !== getExt(second)) {
            return {ok: false, error: 'extensionMismatch'};
        }
        if (ext !== 'csv' && ext !== 'tsv') {
            return {ok: false, error: 'unsupportedType'};
        }
        const delimiter = ext === 'tsv' ? TAB : COMMA;
    
        const a = new Uint8Array(await first.arrayBuffer());
        const b = new Uint8Array(await second.arrayBuffer());
        const startA = bomLength(a);
        const startB = bomLength(b);
        if (a.length <= startA || b.length <= startB) {
            return {ok: false, error: 'empty'};
        }
        if (!isValidUtf8(a) || !isValidUtf8(b)) {
            return {ok: false, error: 'invalidEncoding'};
        }
        const scanA = scanCsv(a, startA, delimiter);
        const scanB = scanCsv(b, startB, delimiter);
        if (!scanA || !scanB) {
            return {ok: false, error: 'malformedCsv'};
        }
    
        const headerA = a.subarray(startA, scanA.headerEnd);
        const headerB = b.subarray(startB, scanB.headerEnd);
        if (headerA.length !== headerB.length || headerA.some((v, i) => v !== headerB[i])) {
            return {ok: false, error: 'headerMismatch'};
        }
    
        const body = b.subarray(scanB.bodyStart);
        const needsSeparator = body.length > 0 && a[a.length - 1] !== LF;
        const separator = needsSeparator ? new TextEncoder().encode(scanA.newline ?? scanB.newline ?? '\n') : new Uint8Array(0);
    
        return {ok: true, file: new File([a, separator, body], first.name, {type: first.type})};
    }

    3. Wire into ImportSpreadsheet.tsx

    • With 2 files, call mergeSpreadsheetFiles. On ok, continue the existing flow (column mapping, then importMultiLevelTags in Tag.ts) with the merged File. On error, show a modal with the matching message.
    • With 1 file, behavior is identical to today.
    • Add translation keys for each MergeError in en.ts and es.ts. Confirm at the commit whether other locales need entries.
    • Parsing and merging ~100k rows is a single linear byte scan per file. Verify on a ~100k-row fixture that it doesn't block the UI noticeably.

    4. Tests

    • Unit tests for mergeSpreadsheetFiles:
      • LF and CRLF inputs, and file 1 with and without a trailing newline
      • Trailing empty cells and trailing spaces preserved byte-for-byte
      • Quoted fields with embedded LF/CRLF, including in the header
      • Escaped quotes ("")
      • BOM on one, both, or neither file
      • .csv+.tsv mismatch, .xlsx rejected, 0-byte and BOM-only files
      • Invalid UTF-8 and UTF-16 input
      • Unbalanced quote, a"b in an unquoted field, text after a closing quote, bare CR
      • Header mismatch
      • Header-only file 1 or file 2
      • Output row count equals rows1 + rows2
    • UI tests:
      • Selecting 3 files shows the error.
      • Selecting 2 files makes exactly one API call with a single merged file.
      • Dropping 2 files behaves the same as picking 2.

    What alternative solutions did you explore? (Optional)

    • Two sequential imports, no API change: Rejected if ImportMultiLevelTags replaces all tags, since the second call would overwrite the first. This is an assumption to confirm (see the backend prerequisite).
    • String concatenation (trimEnd() + split on \n): Rejected. It drops valid trailing whitespace and empty cells, breaks CRLF files, and mishandles newlines inside quoted cells.
    • Parse and re-serialize with a CSV library: Rejected as the default. It can silently change quoting and whitespace, and it is heavier at 100k rows.
    • Raise the documented 50k limit client-side only: Rejected. It doesn't address any backend limit.

    Contributor: @tuananh4865
    Email: tuananh4865@gmail.com
    Upwork: https://www.upwork.com/freelancers/~0146a4de0ca9fff602?companyReference=2103308912547901160&mp_source=share

  9. melvin-bot commented on Oct 5, 2026

    @melvin-bot

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

  10. melvin-bot commented on Oct 7, 2026

    @melvin-bot

    @ChavdaSachin Eep! 4 days overdue now. Issues have feelings too...

  11. melvin-bot commented on Oct 9, 2026

    @melvin-bot

    @ChavdaSachin Still overdue 6 days?! Let's take care of this!

  12. 24 remaining items

  13. amyevans commented on Nov 4, 2026

    @amyevans
    Contributor

    We don't have a cap on the number of tags allowed in the backend. I see in the linked Slack thread that we asked the customer to test with all tags in 1 file (but they haven't yet - confirmed via logs).

    I went ahead and tested with a file containing 100k rows though and it worked:

    Image Image

    So I think we should update the helpdot article to remove the reference to 50k

  14. amyevans commented on Nov 4, 2026

    @amyevans
    Contributor

    @MelvinBot open a PR to update the help article

  15. added
    Reviewing
    on Nov 4, 2026
  16. MelvinBot commented on Nov 4, 2026

    @MelvinBot
    Contributor

    Created a draft PR, assigned to you: Remove incorrect tag import limit from help article.

    It removes the 50,000-tag limit and keeps the CSV/TSV requirement. Spelling and diff checks passed.

    Please mark it ready for review when you're ready, or ask me to do so.


    view run

  17. amyevans commented on Nov 4, 2026

    @amyevans
    Contributor

    I also put up a backend PR with a performance improvement: https://github.com/Expensify/Web-Expensify/pull/57980

  18. added
    Internal
    and removed
    External
    on Nov 4, 2026
  19. added
    Weekly
    and removed
    Daily
    on Nov 4, 2026
  20. Eskalifer1 commented on Nov 4, 2026

    @Eskalifer1
    Contributor

    Is there any work i should do @amyevans?

  21. amyevans commented on Nov 4, 2026

    @amyevans
    Contributor

    Nope I think we are all set. Thank you though!

  22. expensify-chore-bot commented on Nov 27, 2026

    @expensify-chore-bot

    This issue has not been updated in over 15 days. @amyevans eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

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

Metadata

Metadata

Assignees

Labels

BugInternalMonthlyReviewing

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions