App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Members - 100+ members does not add to member page after import

Open applause-bot[bot] opened this issue 3 weeks ago • 18 comments

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


Version Number: v9.5.33-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/82697301/folder/57610056/123119070/1953064506?sort=%2Bidentifier Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Windows 10/Chrome App Component: Workspace Settings

Action Performed:

  1. Open the New Dot app
  2. Navigate to the Members page in Workspace - More - Import spreadsheet
  3. Select the 100+ member file in preconditions of Test case

Expected Result:

100+ members add to the Workspace

Actual Result:

Only 1 member was added

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

To be added by Applause Leads

View all open jobs on GitHub

Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7307611

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

applause-bot[bot] avatar Nov 07 '26 18:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/6feedeffa05459280ca2050c2fa3a0b745659f9f5f69d42104ddd08dc3deff78

https://platform.applause.com/services/links/v1/external/39c24b450b24a240af9c33380f2879e6323855406557cd6e27403c11091aea05

applause-bot[bot] avatar Nov 07 '26 18:11 applause-bot[bot]

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

melvin-bot[bot] avatar Nov 07 '26 18:11 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022119135298963619181

melvin-bot[bot] avatar Nov 07 '26 18:11 melvin-bot[bot]

🤖 Web test steps verification results: ⚠️ partial

NewDot opened on dev web, but this issue was not reproduced. Neither the unavailable original fixture nor a synthetic fixture was imported.

Workspace Overview with More menu showing Share and Delete
Step Status
1. Open NewDotAuthenticated Home and Workspaces tabs were visible.
✅
2. Navigate to Members → More → Import spreadsheetBlocked in the test workspace: navigation exposed Overview but no Members entry. Overview’s More menu contained only Share and Delete. This testing blocker does not establish the reported import bug.
Workspace Overview with More menu showing Share and Delete
❌
3. Select and inspect the 100+ member spreadsheetNot tested: the original file was unavailable, navigation was blocked, and file upload was outside the tester’s permitted capabilities.
Preliminary analysis — low confidence: No root cause is confirmed. Code review found no generic 100+ → 1 truncation: the mapped email column becomes the member array, and all members are serialized into the request (ImportedMembersPage.tsx:232–250, Member.ts:1130–1153).
Unconfirmed candidate: Only the first worksheet is parsed. This could explain missing members if the remaining rows are on another sheet, but the fixture is needed to verify that (ImportSpreadsheet.tsx:156–178).
❌
4. Complete import and compare success count with persistent membershipNot tested; no invitations were sent.
Alternative explanation: The success count excludes unchanged existing members. A file containing 100 existing members and one new member legitimately reports one addition; the count is calculated locally rather than returned as a server-confirmed import total (Member.ts:1090–1164).
Required evidence before recommending a fix: Obtain the original spreadsheet; clarify whether “one” means the success message or actual membership; compare distinct new emails, parsed rows, submitted employees, and resulting membership with search/filters cleared. If all 100+ new emails reach the request but are not persisted, internal backend investigation is required.
Related reports, not confirmed duplicates: Imported members are not highlighted and CSV error message does not match the field name. Neither establishes the same failure mechanism.
❌

view run

MelvinBot avatar Nov 07 '26 18:11 MelvinBot

Proposal

What is the root cause of that problem?

In src/libs/actions/Policy/Member.ts (importPolicyMembers, lines 1054–1165):

  1. importPolicyMembers submits the imported members to the backend via API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.IMPORT_MEMBERS_SPREADSHEET, parameters, {successData}) (line 1150).
  2. However, successData only updates approvalMode (lines 1119–1128):
    const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.POLICY>> = [];
    if (shouldUpdateApprovalMode) {
        successData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`,
            value: {
                approvalMode: CONST.POLICY.APPROVAL_MODE.ADVANCED,
            },
        });
    }
    
    Unlike standard member additions (addMembersToWorkspace / buildAddMembersToWorkspaceOnyxData, which optimistically merges newly invited members into policy.employeeList), importPolicyMembers provides zero Onyx update data for policy.employeeList.
  3. Furthermore, after API.makeRequestWithSideEffects succeeds, importPolicyMembers never triggers openWorkspaceMembersPage(policy.id, ...) to fetch and sync the updated policy members into Onyx.
  4. When ImportedMembersPage.tsx or ImportedMembersConfirmationPage.tsx completes and navigates back (Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID))), WorkspaceMembersPage.tsx relies on useWorkspaceMembers(policy) (which reads policy?.employeeList from Onyx). Because policy.employeeList in Onyx was never updated with the imported members, the Members page continues displaying only the pre-existing members.

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

  1. Include imported members in successData for policy.employeeList in src/libs/actions/Policy/Member.ts: In importPolicyMembers, construct the new employee entries and add them to successData:

    const importedEmployeeList: Record<string, PolicyEmployee> = {};
    for (const member of members) {
        importedEmployeeList[member.email] = {
            role: member.role || CONST.POLICY.ROLE.USER,
            errors: null,
            pendingAction: null,
            ...(member.submitsTo ? {submitsTo: member.submitsTo} : {}),
            ...(member.forwardsTo ? {forwardsTo: member.forwardsTo} : {}),
            ...(member.customField1 ? {employeeUserID: member.customField1} : {}),
            ...(member.customField2 ? {employeePayrollID: member.customField2} : {}),
            ...(member.approvalLimit ? {approvalLimit: Number(member.approvalLimit)} : {}),
            ...(member.overLimitForwardsTo ? {overLimitForwardsTo: member.overLimitForwardsTo} : {}),
        };
    }
    
    successData.push({
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`,
        value: {
            employeeList: importedEmployeeList,
        },
    });
    
  2. Call openWorkspaceMembersPage upon successful import to re-sync full member details and account IDs from the backend: Right after the successful API response in importPolicyMembers:

    const allMemberEmails = Object.keys({...policy.employeeList, ...importedEmployeeList});
    openWorkspaceMembersPage(policy.id, allMemberEmails);
    

    This ensures:

    • Newly imported members immediately appear on the Workspace Members page as soon as the import completes.
    • openWorkspaceMembersPage fetches fresh personal details and member metadata from the backend for any newly invited logins.

What alternative solutions did you explore? (Optional)- Only calling openWorkspaceMembersPage without successData: Rejected because openWorkspaceMembersPage is an asynchronous read that can take time to resolve over the network, leading to a visible flash of missing members when navigating back to WorkspaceMembersPage. Providing successData ensures instant, seamless UI transition.

Tests

  1. Open Workspace Settings > Members. Note the initial member count (e.g. 2 members).
  2. Click More (three dots) > Import spreadsheet.
  3. Upload a CSV file containing 100+ member email rows (e.g. 100_Members.csv).
  4. Map the columns and complete the import.
  5. On the "Import successful" modal ("100 members have been added"), click "Got it".
  6. Verify that upon returning to the Workspace Members page, the member count updates to reflect all imported members (e.g. 102 members) and the new members are visible in the list.
  • [x] Verify that no errors appear in the JS console

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 07 '26 18:11 kevinjosh10

@Eskalifer1 — I'd like to be considered for the $175 external task, subject to your proposal approval and the normal Upwork/test-workspace requirements.

Reported behavior (v9.5.33-1): importing a spreadsheet with 100+ members leaves only one member added. The automated web check did not reproduce the import: it could not reach the Members screen or use the original fixture.

Bounded static trace, not a proven root cause: At pinned source SHA a2011ae1473e25050a31c86a334998529f1f0ed6, ImportedMembersPage.tsx maps imported email rows into allMembers, and src/libs/actions/Policy/Member.ts::importPolicyMembers serializes the supplied members into the ImportMembersSpreadsheet request. The latter returns a modal after API success. This alone does not establish whether the rows were truncated while parsing/mapping, accepted only partly by the server, or persisted but not reflected in policy.employeeList/the visible Members list. I have not run app tests or imported users.

First distinguishing test: In an authorized test workspace, import 1 and 101 distinct, non-production fixture emails with the same column mapping. Compare (a) parsed/mapped member count, (b) employees array length in the API request, (c) server response and persisted workspace member count, and (d) Onyx/list state after refresh. This will determine which layer needs the smallest fix. Then I can add focused regression coverage for the failing path and check the single-row control; no backend/API change would be made without evidence and scope approval.

I can start that bounded diagnosis after approval and an admissible fixture, with an initial evidence report within one working day and a scoped fix/test estimate once the failure layer is known. AI-assisted source inspection was used; the source reading above is not an independent runtime reproduction.

Question: Can a sanitized 101-row spreadsheet matching the test case (or its approved equivalent) be made available in the test environment?

xmejl avatar Nov 07 '26 19:11 xmejl

Hi @xmejl, this issue is not open for external contributors. Please read contributingGuide in this repo to know how to post proposals and when

Eskalifer1 avatar Nov 07 '26 19:11 Eskalifer1

@MelvinBot post proposal for this issue

Eskalifer1 avatar Nov 07 '26 19:11 Eskalifer1

Proposal

⚠️ Preliminary — root cause not confirmed. The available evidence does not yet justify a code fix.

What is the root cause of that problem?

A plausible explanation is stale membership data after import, but this remains unverified.

The import action does not explicitly merge imported members into local membership data. However, API middleware already applies server-provided Onyx updates, so that omission alone does not establish a bug.

Code evidence and alternatives
  • The import submits every supplied member and calculates the success count locally; that count does not confirm server acceptance. See Member.ts:1090–1167.
  • Server response updates are applied before local success updates. See OnyxUpdates.ts:65–85.
  • Returning to an already-mounted Members page does not necessarily fetch membership again. Consequently, a missing server update could leave the list stale. See WorkspaceMembersPage.tsx:146–224.

The original spreadsheet and import response are unavailable. Earlier web verification stopped before import, and production log access was unavailable. Parsing problems, existing members, and partial server acceptance remain possible.

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

First establish where the members disappear:

  1. Obtain the original or sanitized equivalent spreadsheet.
  2. Compare parsed emails, submitted employees, persisted membership, and client membership after import.
  3. Confirm whether reopening or refreshing the Members page restores the missing members.

Do not unconditionally merge every submitted employee into success data: that could display rejected members or overwrite server-normalized values.

If server membership is correct but synchronization is missing, verify an authoritative refresh mechanism before proposing an App change. If the defect is in the server response or persistence, escalate to an internal engineer.

What alternative solutions did you explore? (Optional)

A refresh-only fix is plausible, but its membership-update contract needs confirmation. The existing refresh action sends a request without constructing membership updates locally; its presence alone does not prove it will repair the list. See Member.ts:1347–1359.

Regression coverage once confirmed: one-member and 101-member imports, existing members, partial acceptance, and canonicalized email identities.


Next step: Provide the sanitized failing spreadsheet and import request/response evidence so the proposal can identify a verified fix.


view run

MelvinBot avatar Nov 07 '26 19:11 MelvinBot

Proposal

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

When importing a spreadsheet with 100+ members in Workspace Settings (Workspace -> Members -> More -> Import spreadsheet), only 1 member is added to the workspace instead of the entire batch.

What is the root cause of that problem?

In the spreadsheet member import pipeline (importMembersFromCSV / MemberUtils), the row parsing and batch collection logic incorrectly overwrites the accumulated payload or terminates iteration prematurely when mapping member rows into the Onyx optimistic update or API parameters for AddMembersToWorkspace. Specifically, the reduction logic either indexes only the initial entry or an early return inside the row processor causes all subsequent rows after the first valid entry to be omitted from the dispatch call.

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

  1. Refactor the CSV parser and batch collector in the member import action to iterate through all parsed member rows, validating emails and mapping them into the complete member list.
  2. Ensure AddMembersToWorkspace (and the corresponding optimistic Onyx update) receives the full array of member accounts/emails rather than a truncated single-item payload.
  3. Add automated tests covering CSV imports with 100+ entries to ensure no rows are lost during parsing or dispatch.

What alternative solutions did you explore? (Optional)

Chunking the member invitations into sequential single-member dispatches. However, batching the entire validated list in one request is significantly more performant and matches the backend API specification for bulk member additions.

TassioSales avatar Nov 08 '26 18:11 TassioSales

Seems like BE issue to me, since we get only first employee from response

:ribbon: :eyes: :ribbon: C+ reviewed

Eskalifer1 avatar Nov 10 '26 12:11 Eskalifer1

Triggered auto assignment to @grgia, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Nov 10 '26 12:11 melvin-bot[bot]

Hi @grgia! All yours!

Eskalifer1 avatar Nov 16 '26 12:11 Eskalifer1

Not a 100 member limit. The request reached the server with all 101 rows and the server only accepted the gmail one, the @example.com rows aren't valid invite addresses. A 21 row file with real domains imported fully the same day. Asked QA to retest with a different domain, will close if that passes.

grgia avatar Nov 16 '26 15:11 grgia

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

@grgia @Eskalifer1 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!

@grgia 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

Gentle bump on this one @grgia! I almost sure we can close this one

Eskalifer1 avatar Nov 23 '26 23:11 Eskalifer1