Skip to content

[Due for payment 2026-07-17] [$250] CSV card feed import succeeds but no cards are created (no validation for missing required fields) #93704

Closed

Description

@m-natarajan

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


Version Number: v9.4.8-0
Reproducible in staging?: Y
Reproducible in production?: Y
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: @Leeckhart
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Navigate to Workspace > Company Cards.
  2. Create a new CSV Import card feed.
  3. Upload a spreadsheet containing card transaction data with columns such as: Card Last 4, Spender, Merchant, Transaction Currency, Total Amount, (Missing: Date column)
  4. Complete the import process.
  5. Open the newly created card feed.

Expected Result:

The import process should validate required fields (including Date, if mandatory).
If a required column is missing, the system should:
Display a clear validation error, and/or
Prevent feed creation until the file is corrected.
If the file is valid, cards should appear in the feed after import.

Actual Result:

The CSV feed is created successfully.
No cards are added to the feed.
The feed displays: “No cards in this feed”
No validation error or warning is shown indicating that required data (e.g., Date column) is missing.

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.3023.mp4

View all open jobs on GitHub

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 16, 2026
  2. added and removed on Jun 16, 2026
  3. MelvinBot commented on Jun 16, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The CSV company-card import only validates that a column is assigned to each required role — it never checks that the assigned column actually contains valid data. So when the spreadsheet has no Date column, the user can still satisfy the "Date is required" rule by mapping any other column (e.g. Spender) to Date, and validation passes.

    validate() only flags a required role if it is unmapped — it does not inspect cell values:

    const missingRequiredColumns = requiredColumns
        .filter((requiredColumn) => !columns.includes(requiredColumn.value))
    

    Two things then combine to hide the failure:

    1. The "Import successful" modal reports an optimistic, frontend-computed count, not the number of cards the backend actually created. In importCSVCompanyCards, transactionsCount = transactions.length (rows the client built from the CSV) is passed straight into the success modal. As long as the API returns 200, success is shown regardless of how many cards were imported.
    2. The backend CSV scraper (CCUploadScraper.php, Server-Scraper repo) silently drops rows whose dates don't parse — a known "corrupted date → 0 files processed" path — so the feed is created with no cards and no error surfaced.

    The net effect: feed created → "No cards in this feed" → no validation error, exactly as reported.

    Evidence & data flow
    • Required roles (Date = POSTED_DATE, labeled "Date") are declared at CompanyCardsImportedPage.tsx:53-77.
    • importTransactions() re-runs validate() and blocks the API call only when a role is unmapped — never based on cell contents.
    • Repro spreadsheet columns were Card Last 4, Spender, Merchant, Transaction Currency, Total Amount (no date). To clear the required-Date check, a non-date column had to be mapped to Date; the backend then couldn't parse those values into dates.
    • The optimistic success modal is built before the backend responds: CompanyCards.ts:1156-1163.

    Note (cross-repo): the silent "0 transactions imported, no error" behavior lives in CCUploadScraper.php in the Server-Scraper repo, which is outside Expensify/App. A complete fix should also have the backend report invalid-date / zero-imported errors, but that change requires an internal engineer with access to that repo and can't be made here.

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

    Add value-level validation to the column-mapping step so the import is blocked (with a clear error) when a required column's data is invalid — specifically, when the column mapped to Date does not contain parseable dates.

    • In CompanyCardsImportedPage.tsx's validate(), after confirming Date is mapped, sample the values of the column mapped to POSTED_DATE and verify they parse as dates; if they don't, set a new error (e.g. csvErrors.invalidDateColumn) and surface it above the Import button the same way the existing errors.required message is shown.
    • Use a lenient date check so legitimate formats aren't rejected — the goal is to catch "this clearly isn't a date column," not to enforce one exact format.

    This directly delivers the issue's expectation: a clear validation error that prevents feed creation until the file is corrected.

    What alternative solutions did you explore? (Optional)

    • Have the success modal display the backend-reported imported count instead of the optimistic transactions.length, so "0 cards imported" shows a warning rather than a success message. (Requires the backend to return the real count.)
    • Backend fix in CCUploadScraper.php (Server-Scraper) to reject the upload or return an error when all rows have unparseable/missing dates. Best done in tandem with the frontend change, but it's outside this repo.

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

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 16, 2026
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 16, 2026
  6. MobileMage commented on Jun 16, 2026

    @MobileMage
    Contributor

    Proposal

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

    When a CSV company-card feed is imported with a file that is missing required transaction data (e.g. no usable Date column), the import reports success and the feed is created, but zero cards/transactions are added. The user lands on an empty "No cards in this feed" state with no validation error explaining what went wrong, even though the data was effectively rejected.

    What is the root cause of that problem?

    The CSV import has two validation gates, and both let a "no usable data" file through. The import is driven from CompanyCardsImportedPage. Its validate() only checks that each required column role (cardNumber, postedDate, merchant, amount, currency) has been assigned to some column — it never inspects whether those mapped columns actually contain parseable values:

    const missingRequiredColumns = requiredColumns
    .filter((requiredColumn) => !columns.includes(requiredColumn.value))
    .map((requiredColumn) => requiredColumn.text)
    .join(', ');
    if (missingRequiredColumns) {
    errors.required = translate('workspace.companyCards.addNewCard.csvErrors.requiredColumns', missingRequiredColumns);

    So the check is purely role-presence, not data-presence:

    const missingRequiredColumns = requiredColumns
        .filter((requiredColumn) => !columns.includes(requiredColumn.value))

    This passes as long as columns are mapped. But auto-detection in ImportColumn.findColumnName will also remap a Date header onto POSTED_DATE (and similar fuzzy matches), so a column can be mapped to postedDate while holding values that aren't real dates. Once validate() passes, importTransactions calls importCSVCompanyCards, which builds the optimistic transactions in buildOptimisticCompanyCardCSVTransactions. That function silently drops every row whose required cells are empty or unparseable via a continue, so a missing/garbage Date column zeroes out the entire import:

    const amount = parseCSVAmount(amountValue);
    if (!cardName || !created || !currency || amount === undefined) {
    continue;
    }

    The result is transactions.length === 0, yet the feed is still created (shouldCreateFeed write at CompanyCards.ts L1178-1203) and the success modal is shown unconditionally with titleKey: 'spreadsheet.importSuccessfulTitle'. Worse, importCompanyCardTransactionsSuccessfulDescription falls into its else branch for a count of 0 and tells the user "1 transaction has been added." The contrast with the sibling importer is the key: ImportedCategoriesPage.validate() already inspects the mapped column's data and blocks on empty values (containsEmptyName → spreadsheet.emptyMappedField), but the company-cards page has no equivalent data-level check.

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

    Add a data-level validation step to CompanyCardsImportedPage.validate(), mirroring the existing containsEmptyName pattern in ImportedCategoriesPage. After the role-presence and duplicate checks pass, locate each mapped required column, read its values from spreadsheet?.data, skip the header row when containsHeader is true, and if any required column has an empty value (or, for the date/amount columns, a value that fails the same parse the action uses), surface an emptyMappedField error keyed to that column so the Import button's OfflineWithFeedback displays it and the early return in importTransactions (L112-114) blocks feed creation. Conceptually:

    const requiredColIndexes = requiredColumns.map((c) => columns.findIndex((v) => v === c.value));
    const hasEmptyRequiredCell = requiredColIndexes.some((colIdx) =>
        spreadsheet?.data?.[colIdx]?.some((cell, i) => (!containsHeader || i > 0) && !cell?.toString().trim()),
    );

    This is safe because it runs only after all required roles are mapped, reuses the established emptyMappedField translation and the same containsHeader row-offset logic already shipped for categories, and changes nothing in the write path or for valid files. As a defensive backstop for cases that still parse to zero rows (e.g. every date is malformed), importCSVCompanyCards should short-circuit when transactions.length === 0 and return getImportFailedFinalModal() instead of creating the feed and showing the success modal, so a "valid columns / no usable rows" file can never produce a phantom empty feed.

    What alternative solutions did you explore? (Optional)

    Disabling the Import button whenever validationErrors is non-empty (today it's only gated on isOffline). That improves discoverability but doesn't fix the underlying gap — the button-disable still relies on role-presence validation, so a file with mapped-but-empty required columns would remain enabled and still create an empty feed; the data-level check is the actual fix.

  7. lorretheboy commented on Jun 16, 2026

    @lorretheboy
    Contributor

    Proposal

    What is the root cause of that problem?

    CSV import validates column mapping but never validates that the mapped cells actually hold data, and rows missing required values are dropped silently.

    The only upstream check (validate in CompanyCardsImportedPage) just confirms each required role is assigned to some column — not that those columns contain values:

    const missingRequiredColumns = requiredColumns
    .filter((requiredColumn) => !columns.includes(requiredColumn.value))
    .map((requiredColumn) => requiredColumn.text)
    .join(', ');
    if (missingRequiredColumns) {
    errors.required = translate('workspace.companyCards.addNewCard.csvErrors.requiredColumns', missingRequiredColumns);

    Then, per row, buildOptimisticCompanyCardCSVTransactions silently continues whenever a required field (cardName/created/currency/amount) is empty — e.g. a missing/empty Date column makes created empty for every row:

    if (!cardName || !created || !currency || amount === undefined) {
    continue;
    }

    So transactions comes back empty, but importCSVCompanyCards never guards on the count — it unconditionally calls API.write, which still creates the feed (shouldCreateFeed) and resolves the success modal:

    const transactionsCount = transactions.length;

    return API.write(WRITE_COMMANDS.IMPORT_CSV_COMPANY_CARDS, parameters, {optimisticData, successData, failureData})

    The success copy even hides the zero — for 0 it falls into the else branch and reads "1 transaction has been added.":

    App/src/languages/en.ts

    Lines 1168 to 1169 in bf205a7

    importCompanyCardTransactionsSuccessfulDescription: ({transactions}: {transactions: number}) =>
    transactions > 1 ? `${transactions} transactions have been added.` : '1 transaction has been added.',

    Chain: header-only validation passes → every row dropped silently → 0 transactions → no zero-count guard → feed created + "success" shown → "No cards in this feed", no error.

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

    Guard the convergence point. In importCSVCompanyCards, when transactions.length === 0 (after parsing), do not call API.write/create the feed — return an error modal telling the user no valid rows were found, so the failure is surfaced instead of a false success:

    const transactionsCount = transactions.length;

    For example, when transactionsCount === 0, return getImportFailedFinalModal() (with copy clarifying that required fields like Date were empty) and skip the write.

    Also fix the misleading success copy so 0 doesn't render as "1 transaction has been added.":

    App/src/languages/en.ts

    Lines 1168 to 1169 in bf205a7

    importCompanyCardTransactionsSuccessfulDescription: ({transactions}: {transactions: number}) =>
    transactions > 1 ? `${transactions} transactions have been added.` : '1 transaction has been added.',

    What alternative solutions did you explore? (Optional)

    Surface the problem earlier in CompanyCardsImportedPage.validate by counting how many data rows have a value for each required column and blocking import (with a clear error) when a required column has no usable data — preventing the empty feed from being created at all.

  8. ahmdshrif commented on Jun 16, 2026

    @ahmdshrif
    Contributor

    Proposal

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

    A CSV company-card import shows "Import successful" and creates the feed, but no cards appear and no error explains that a required field (e.g. Date) yielded no usable rows.

    What is the root cause of that problem?

    Validation only covers column mapping — nothing checks the row data or the resulting card count, so an import that yields zero cards still reports success and creates an empty feed.

    1. validate() only flags unmapped required roles / duplicate mappings; it never inspects the actual cell values:
      const validate = () => {
      const columns = Object.values(spreadsheet?.columns ?? {});
      let errors: Errors = {};
      const missingRequiredColumns = requiredColumns
      .filter((requiredColumn) => !columns.includes(requiredColumn.value))
      .map((requiredColumn) => requiredColumn.text)
      .join(', ');
      if (missingRequiredColumns) {
      errors.required = translate('workspace.companyCards.addNewCard.csvErrors.requiredColumns', missingRequiredColumns);
      } else {
      const duplicate = findDuplicate(columns);
      if (duplicate) {
      errors.duplicates = translate('workspace.companyCards.addNewCard.csvErrors.duplicateColumns', duplicate);
      } else {
      errors = {};
      }
      }
      return errors;
      };
    2. buildOptimisticCompanyCardCSVTransactions silently continues past every row whose required value (cardName / created / currency / amount) is missing or unparseable, so a file with no usable Date (or any missing required value) yields transactions = []:
      for (const row of csvDataWithGeneratedIDs) {
      const transactionID = rand64();
      row[externalIDColumnIndex] = transactionID;
      const cardName = row.at(cardNumberColumnIndex)?.trim();
      const created = row.at(postedDateColumnIndex)?.trim();
      const merchant = row.at(merchantColumnIndex)?.trim() ?? '';
      const currency = row.at(currencyColumnIndex)?.trim();
      const amountValue = row.at(amountColumnIndex) ?? '';
      const amount = parseCSVAmount(amountValue);
      if (!cardName || !created || !currency || amount === undefined) {
      continue;
      }
      const category = categoryColumnIndex >= 0 ? (row.at(categoryColumnIndex)?.trim() ?? '') : '';
      const tag = tagColumnIndex >= 0 ? (row.at(tagColumnIndex)?.trim() ?? '') : '';
    3. importCSVCompanyCards computes transactionsCount but uses it only as a display param — the modal is hardcoded to importSuccessfulTitle and the feed is still created via shouldCreateFeed, regardless of count:
      const transactionsCount = transactions.length;
      const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER | typeof ONYXKEYS.COLLECTION.LAST_SELECTED_FEED>> = [
      {
      onyxMethod: Onyx.METHOD.MERGE,
      key: `${ONYXKEYS.COLLECTION.LAST_SELECTED_FEED}${policyID}`,
      value: feedNameWithDomainID as CompanyCardFeedWithDomainID,
      },
      ];
      const importFinalModal: ImportFinalModal = {
      titleKey: 'spreadsheet.importSuccessfulTitle',
      promptKey: 'spreadsheet.importCompanyCardTransactionsSuccessfulDescription',
      promptKeyParams: {
      transactions: transactionsCount,
      },
      pendingMessageKey: 'spreadsheet.importCompanyCardTransactionsPendingMessage',
      };

    Chain explains every symptom: feed created ✓, zero cards ✓, no validation error ✓.

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

    Gate the result in the single import action importCSVCompanyCards: when transactionsCount === 0, return the existing getImportFailedFinalModal() and skip pushing the create-feed optimisticData, so the user sees a clear failure instead of an empty feed. The copy already fits — "Please ensure all fields are filled out correctly and try again":

    App/src/languages/en.ts

    Lines 1191 to 1192 in bf205a7

    importFailedTitle: 'Import failed',
    importFailedDescription: 'Please ensure all fields are filled out correctly and try again. If the problem persists, please reach out to Concierge.',

    const transactionsCount = transactions.length;
    if (transactionsCount === 0) {
        return Promise.resolve(getImportFailedFinalModal());
    }

    Regression-safe: any file with ≥1 valid row takes the unchanged success path; both basic and advanced-field layouts flow through this one action.

    What alternative solutions did you explore? (Optional)

    • Row-value checks in validate() + block in importTransactions: works but duplicates producer logic and a new copy key, and still creates the feed — gating the central action covers it once.
    • Strengthen column-mapping validation only — incomplete: can't catch a mapped-but-empty/invalid Date column, which is the reported case (the feed was created, so mapping validation already passed).
  9. 68 remaining items

  10. melvin-bot commented on Jul 15, 2026

    @melvin-bot

    @shubham1206agra Huh... This is 4 days overdue. Who can take care of this?

  11. shubham1206agra commented on Jul 16, 2026

    @shubham1206agra
    Contributor

    Payment tomorrow

  12. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jul 16, 2026
  13. melvin-bot commented on Jul 16, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  14. melvin-bot commented on Jul 16, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • 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/2066883484768848009/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
  15. mallenexpensify commented on Jul 20, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @shubham1206agra due $250 via NewDot

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

  16. shubham1206agra commented on Jul 21, 2026

    @shubham1206agra
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to the comment on the PR: https://github.com/Expensify/App/pull/80636/changes#r3623617169
      Link to the comment on the Issue: NA

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: NA

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/662927

    Regression Test Proposal

    Test:

    1. Go to Workspace > Company Cards > Add cards > USA > Import from file and import a file with an empty column.
    2. Map the mandatory fields.
    3. Verify that it shows the validation error about empty required column.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-420b-a001-4f78-22d8785be794
  17. shubham1206agra commented on Jul 21, 2026

    @shubham1206agra
    Contributor

    @mallenexpensify Please close this issue now

  18. JmillsExpensify commented on Aug 10, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @shubham1206agra

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.DailyKSv2InternalRequires API changes or must be handled by Expensify staff

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions