Skip to content

Name assigned company card after the selected employee, not the admin - #97925

Merged
carlosmiceli merged 2 commits into
mainfrom
claude-assignedCardNameUsesAssignee
Aug 14, 2026
Merged

Name assigned company card after the selected employee, not the admin#97925
carlosmiceli merged 2 commits into
mainfrom
claude-assignedCardNameUsesAssignee

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

When assigning a company card, the card was being named after the wrong person (e.g. the admin's account) instead of the employee it was actually assigned to.

Root cause was that customCardName gets populated early and then a set of guards refused to recompute it once set, so switching the assignee left the earlier name in place. Two cooperating defects:

  1. Single active-employee shortcut picked the wrong email. In useInitialAssignCardStep (src/hooks/useAssignCard.ts), the length === 1 check ran on the filtered (non-deleted) employee list, but userEmail was read from Object.keys(policy.employeeList).at(0) — the unfiltered first key. When the first employee was pending deletion, the card was pre-named after that stale/admin account instead of the single remaining active member. Fixed by deriving the email from the same filtered list used for the count.

  2. Stale guards never recomputed the name when the assignee changed. AssigneeStep only set customCardName when it was empty and otherwise fell back to the stored value (customCardName ?? defaultCardName), so selecting a different assignee kept the previously stored name. Fixed by recomputing the card name from the currently selected assignee, while preserving a name the user manually typed in CardNameStep (tracked with a new isCustomCardNameEdited flag).

Also applied the same "name follows the current member" logic and a name-vs-email consistency fix to InviteNewMemberStep, which previously seeded the name from the raw email.

Approved proposal: #97692 (comment)

Fixed Issues

$ #97692
PROPOSAL: #97692 (comment)

Tests

  1. Sign in as a workspace admin.
  2. Navigate to Workspace > Company Cards and select a CSV/commercial feed.
  3. Click Assign on an unassigned company card.
  4. On the Assignee step, select an employee that is not the admin.
  5. Proceed to the Confirmation step and verify the card name reads <selected employee>'s card (not the admin's).
  6. Go back to the Assignee step and select a different employee, then return to Confirmation.
  7. Verify the card name now reflects the newly selected employee.
  8. Go to the Card name step, manually type a custom name, save, then go back and change the assignee again.
  9. Verify the manually typed name is preserved (not overwritten by the assignee's default name).
  • Verify that no errors appear in the JS console

Offline tests

Same as tests.

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Co-authored-by: Qichen Zhu <QichenZhu@users.noreply.github.com>
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/hooks/useAssignCard.ts 81.81% <100.00%> (+6.06%) ⬆️
...workspace/companyCards/assignCard/CardNameStep.tsx 0.00% <ø> (ø)
...workspace/companyCards/assignCard/AssigneeStep.tsx 60.91% <0.00%> (+1.36%) ⬆️
...ce/companyCards/assignCard/InviteNewMemberStep.tsx 0.00% <0.00%> (ø)
... and 1068 files with indirect coverage changes

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I looked into the failing checks — none of them are code failures, so there's nothing for me to push a fix for.

The only two red checks are process/human gates:

  • PR Author Checklist / checklist — failing because the author checklist in the PR body has 0/38 boxes ticked. This is a human attestation (tested on all platforms, no console errors, etc.), so I'm intentionally not checking the boxes on your behalf. Please review and tick them.
  • Check independent approval — failing because the PR still needs an approving review from an independent reviewer. Nothing to fix here either; it clears once a reviewer approves.

Everything else that could catch a real problem is green: all 8 test jobs, typecheck, ESLint, Oxfmt, Bun tests, Storybook tests, React Compiler Compliance, spellcheck, all build jobs, validate, knip, and codecov. branch-perf-tests passed; baseline-perf-tests was still running when I checked and isn't code-related.

So no push needed — just complete the author checklist and get a review.

@QichenZhu QichenZhu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
    https://expensify.slack.com/archives/C049HHMV9SM/p1778663561704459
    https://expensify.slack.com/archives/C049HHMV9SM/p1764642854883869
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
    Direct links don't work in this flow on staging, and this PR doesn't change that.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
Screen_recording_20260807_011638.webm
Android: mWeb Chrome
Screen_recording_20260807_011825.webm
iOS: Native
Simulator.Screen.Recording.-.iPhone.17.-.2026-08-07.at.01.16.05.mov
iOS: mWeb Safari
Screen.Recording.2026-08-07.at.1.21.21.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-07.at.12.51.36.AM.mov

@melvin-bot
melvin-bot Bot requested a review from carlosmiceli August 6, 2026 13:32
@QichenZhu

Copy link
Copy Markdown
Contributor

Author checklist

Offline tests

N/A.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
    https://expensify.slack.com/archives/C049HHMV9SM/p1778663561704459
    https://expensify.slack.com/archives/C049HHMV9SM/p1764642854883869
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
    Direct links don't work in this flow on staging, and this PR doesn't change that.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen_recording_20260807_011638.webm
Android: mWeb Chrome
Screen_recording_20260807_011825.webm
iOS: Native
Simulator.Screen.Recording.-.iPhone.17.-.2026-08-07.at.01.16.05.mov
iOS: mWeb Safari
Screen.Recording.2026-08-07.at.1.21.21.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-07.at.12.51.36.AM.mov

@carlosmiceli

Copy link
Copy Markdown
Contributor

@QichenZhu is this ready to review?

@carlosmiceli

Copy link
Copy Markdown
Contributor

@QichenZhu also, could we add videos to the PR?

@QichenZhu

Copy link
Copy Markdown
Contributor

is this ready to review?

@carlosmiceli yep.

@QichenZhu also, could we add videos to the PR?

Here are the recordings: #97925 (comment).

@carlosmiceli

Copy link
Copy Markdown
Contributor

@QichenZhu can you change the draft status and complete the PR checklist?

carlosmiceli
carlosmiceli previously approved these changes Aug 13, 2026
@carlosmiceli
carlosmiceli marked this pull request as ready for review August 13, 2026 18:49
@carlosmiceli
carlosmiceli requested a review from a team as a code owner August 13, 2026 18:49
@melvin-bot
melvin-bot Bot requested review from QichenZhu and garrettmknight and removed request for a team August 13, 2026 18:49
@melvin-bot

melvin-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

@QichenZhu Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

const personalDetail = getPersonalDetailByEmail(assignee?.login ?? '');
const memberName = personalDetail?.firstName ? personalDetail.firstName : Str.removeSMSDomain(personalDetail?.login ?? '');
const defaultCardName = getDefaultCardName(memberName);
// Keep the name the user manually typed in CardNameStep; otherwise always recompute it from the currently selected assignee.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-16 (docs)

Comments should read as plain, natural sentences. This comment joins two independent clauses with a semicolon instead of writing them as two separate sentences.

Split it into two sentences:

// Keep the name the user manually typed in CardNameStep. Otherwise always recompute it from the currently selected assignee.
const customCardName = assignCard?.cardToAssign?.isCustomCardNameEdited ? (assignCard?.cardToAssign?.customCardName ?? defaultCardName) : defaultCardName;

Reviewed at: ae2f888 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 78f0cd5 — split into two sentences.

const personalDetail = getPersonalDetailByEmail(invitingMemberEmail);
const memberName = personalDetail?.firstName ? personalDetail.firstName : Str.removeSMSDomain(personalDetail?.login ?? invitingMemberEmail);
const defaultCardName = getDefaultCardName(memberName);
// Keep the name the user manually typed in CardNameStep; otherwise always recompute it from the inviting member.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-16 (docs)

Comments should read as plain, natural sentences. This comment joins two independent clauses with a semicolon instead of writing them as two separate sentences.

Split it into two sentences:

// Keep the name the user manually typed in CardNameStep. Otherwise always recompute it from the inviting member.
const customCardName = assignCard?.cardToAssign?.isCustomCardNameEdited ? (assignCard?.cardToAssign?.customCardName ?? defaultCardName) : defaultCardName;

Reviewed at: ae2f888 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 78f0cd5 — split into two sentences.

@QichenZhu

Copy link
Copy Markdown
Contributor

@MelvinBot please address the review comments.

Co-authored-by: Qichen Zhu <QichenZhu@users.noreply.github.com>
@melvin-bot
melvin-bot Bot removed the request for review from a team August 13, 2026 22:29
@melvin-bot

melvin-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

@carlosmiceli Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Addressed both review comments in 78f0cd5 — split the semicolon-joined comments in AssigneeStep.tsx and InviteNewMemberStep.tsx into two plain sentences per CONSISTENCY-16.

These are comment-only changes (no logic touched), so no tests were needed.

@QichenZhu

Copy link
Copy Markdown
Contributor

@QichenZhu can you change the draft status and complete the PR checklist?

@carlosmiceli we no longer need the author checklist if the author is MelvinBot: https://expensify.slack.com/archives/C02NK2DQWUX/p1786550513486419?thread_ts=1786111493.247829&cid=C02NK2DQWUX

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I looked into the failing checks — there's nothing to fix in the code. All the meaningful checks (typecheck, ESLint, Oxfmt, all builds, all test jobs, Storybook, spellcheck, etc.) are passing.

The only two failing checks are human-gated and can't be resolved by a push:

  • PR Author Checklist / checklist — fails with 0 out of 38 checklist items completed. These are the checkboxes in the PR body's PR Author Checklist section that the author must tick manually. I intentionally don't fill these out on a person's behalf.
  • Check independent approval — fails because the PR still needs an independent reviewer's approval.

QichenZhu, to get these green: tick the PR Author Checklist boxes in the PR description, and have a reviewer approve. The baseline-perf-tests / branch-perf-tests jobs were still running when I checked and are unrelated to this change.

@carlosmiceli

Copy link
Copy Markdown
Contributor

@QichenZhu ah, interesting, was OOO so missed that. Not sure why it's not passing then, but no worries, I'll just check them so it doesn't trigger the emergency.

@carlosmiceli
carlosmiceli merged commit 4f9ce41 into main Aug 14, 2026
46 of 48 checks passed
@carlosmiceli
carlosmiceli deleted the claude-assignedCardNameUsesAssignee branch August 14, 2026 08:05
@github-actions

Copy link
Copy Markdown
Contributor

🚧 carlosmiceli has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/carlosmiceli in version: 9.4.54-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I reviewed the changes in this PR against the help site articles under App/docs/articles and no help site changes are required.

Why: This PR is an internal bug fix to a default value in the assign-company-card flow — the auto-generated default card name (<name>'s card) now follows the currently selected assignee instead of a stale/admin account, and a manually typed name is preserved. It doesn't add a feature, rename anything, or change any documented setting, tab, or button label.

The behavior it fixes isn't documented anywhere in the help site:

Since there's no documented behavior that changed, there's nothing to update and no draft PR to create.

@QichenZhu, if you believe the default card-naming behavior should be documented as net-new content, let me know and I can draft an addition to Assign-Company-Cards.md.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants