[$175] Dependent Tags only accept one uploaded file in New Expensify, preventing customers from uploading more than 50,000 tag rows
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:
- Goes to the workspace in New Expensify.
- Goes to the Tags settings for the workspace.
- Configures multi-level dependent tags used for management reporting.
- Uploads a file containing dependent tag values.
- Attempts to upload an additional file to accommodate tag data exceeding the 50,000-tag limit.
- 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
- [x] Windows: Chrome
- [ ] MacOS: Chrome / Safari
Screenshots/Videos
https://github.com/user-attachments/assets/f9794972-6343-4acc-9404-fd233e30a407
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022106003487272786107
- Upwork Job ID: 2106003487272786107
- Last Price Increase: 2026-10-02
Issue Owner
Current Issue Owner: @amyevans
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.
- The API params carry a single
fileand have no append mode: ImportMultiLevelTagsParams.ts:1-7 - The file picker and drag-and-drop both read only
files[0]: FilePicker/index.tsx:29 and ImportSpreadsheet.tsx:293 - Importing again shows a warning that existing tags will be overridden: en.ts:7226-7230
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:
- On the multi-level import step, let the user add up to two CSV/TSV files.
- Check that both files have the same header row. Show an error if they don't.
- Merge the rows on the client, keeping the header once. Send one merged file through the existing
ImportMultiLevelTagscall (Tag.ts:901-914). The API stays the same. - 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.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ChavdaSachin (External)
Job added to Upwork: https://www.upwork.com/jobs/~022106003487272786107
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:
[email protected] - 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?
- In
src/components/ImportSpreadsheet.tsx:293andsrc/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. FilePickerdoes not support themultipleattribute.
- The drop zone and file input strictly read
- In
src/libs/actions/Policy/Tag.ts:901-925,importMultiLevelTagscallsAPI.write(WRITE_COMMANDS.IMPORT_MULTI_LEVEL_TAGS, ...), which transmits a single file that replaces the workspace's entire multi-level tag tree. - 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?: booleanprop and pass it to the hidden<input type="file" />. - When
multipleis true, passArray.from(event.target.files)toonSelected.
2. In ImportSpreadsheet.tsx:
- Enable
multiple={isImportingMultiLevelTags}onFilePickerandDragAndDropConsumer(allowing up to 2 files). - When 2 files are provided:
- Read both files using
FileReader. - Parse both spreadsheets into row arrays using
parseSpreadsheet. - Validate header compatibility: Ensure both files have identical header rows / column counts. If headers differ, display a clear validation error modal (
translate('spreadsheet.errorMismatchedHeaders')). - Merge row data: Concatenate the data rows of file 2 to file 1 (excluding file 2's duplicate header row).
- Combine them into a single merged
File/ CSV blob and save toONYXKEYS.IMPORTED_SPREADSHEET.
- Read both files using
- Proceed normally through
ImportMultiLevelTagsSettingsPageandimportMultiLevelTags, 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 orisAppendflag to Web-E and orchestrating cross-repo deployments. Client-side merging is cleaner, immediate, and fully compatible with the existing single-file upload pipeline.
Contributor Details
- Contributor:
@tuananh4865 - Email:
[email protected] - 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?
- 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.
- API contract takes one file.
importMultiLevelTagsinsrc/libs/actions/Policy/Tag.ts(~lines 900–930) sends a singlefileparameter. - Backend behavior is unverified (assumption).
- I can't confirm from the client code whether
ImportMultiLevelTagsreplaces 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).
- I can't confirm from the client code whether
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.tsandTag.ts. The client UI and validation in Option A still apply, and only the submit step changes.- B1:
isAppendparameter. The first call sendsisAppend: false, the secondisAppend: true. This is simpler for the backend, but the client must handle a failure between the two calls. - B2: array of files or
file2slot. This matches Classic and is atomic, so a failed import can't leave a half-imported list.
- B1:
Option A: merge two files client-side into one File
1. Selection UI (opt-in, multi-level tags only)
- Add an opt-in
multiple/maxFilesprop toFilePicker(index.tsx:29) and handledataTransfer.filesinImportSpreadsheet.tsx:293. All other import flows keepfiles[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:85to: "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.
- A newline inside a quoted field is data.
- 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. Onok, continue the existing flow (column mapping, thenimportMultiLevelTagsinTag.ts) with the mergedFile. On error, show a modal with the matching message. - With 1 file, behavior is identical to today.
- Add translation keys for each
MergeErrorinen.tsandes.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+.tsvmismatch,.xlsxrejected, 0-byte and BOM-only files- Invalid UTF-8 and UTF-16 input
- Unbalanced quote,
a"bin 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
ImportMultiLevelTagsreplaces 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: [email protected] Upwork: https://www.upwork.com/freelancers/~0146a4de0ca9fff602?companyReference=2103308912547901160&mp_source=share
@ChavdaSachin Whoops! This issue is 2 days overdue. Let's get this updated quick!
@ChavdaSachin Eep! 4 days overdue now. Issues have feelings too...
@ChavdaSachin Still overdue 6 days?! Let's take care of this!
@ChavdaSachin 10 days overdue. Is anyone even seeing these? Hello?
@ChavdaSachin 12 days overdue. Walking. Toward. The. Light...
@ChavdaSachin this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
This issue has not been updated in over 14 days. @ChavdaSachin eroding to Weekly issue.
@ChavdaSachin this issue is now 4 weeks old, please consider:
- Finding a contributor to fix the bug
- Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
- If you have any questions, don't hesitate to start a discussion in #expensify-open-source
Thanks!
@ChavdaSachin Huh... This is 4 days overdue. Who can take care of this?
@ChavdaSachin Eep! 4 days overdue now. Issues have feelings too...
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Eskalifer1 (External)
@Eskalifer1 plz take over as C+
@ChavdaSachin Huh... This is 4 days overdue. Who can take care of this?
Yea, i agree let's get opinion from internal if we can and want to do this
https://github.com/Expensify/App/issues/102888#issuecomment-5952691133
:ribbon: :eyes: :ribbon: C+ reviewed
Triggered auto assignment to @amyevans, see https://stackoverflow.com/c/expensify/questions/7972 for more details.