Name assigned company card after the selected employee, not the admin - #97925
Conversation
Co-authored-by: Qichen Zhu <QichenZhu@users.noreply.github.com>
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
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:
Everything else that could catch a real problem is green: all 8 So no push needed — just complete the author checklist and get a review. |
QichenZhu
left a comment
There was a problem hiding this comment.
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 Issuessection 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
Testssection - I verified the steps for Staging and/or Production testing are in the
QA stepssection - 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 verified the steps for local testing are in the
- 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 usingAvatarhave 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
Avataris modified, I verified thatAvataris 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
Designlabel and/or tagged@Expensify/designso 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
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - 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
|
|
@QichenZhu is this ready to review? |
|
@QichenZhu also, could we add videos to the PR? |
@carlosmiceli yep.
Here are the recordings: #97925 (comment). |
|
@QichenZhu can you change the draft status and complete the PR checklist? |
|
@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. |
There was a problem hiding this comment.
❌ 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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
❌ 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.
There was a problem hiding this comment.
Done in 78f0cd5 — split into two sentences.
|
@MelvinBot please address the review comments. |
Co-authored-by: Qichen Zhu <QichenZhu@users.noreply.github.com>
|
@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] |
|
Addressed both review comments in 78f0cd5 — split the semicolon-joined comments in These are comment-only changes (no logic touched), so no tests were needed. |
@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 |
|
I looked into the failing checks — there's nothing to fix in the code. All the meaningful checks (typecheck, ESLint, Oxfmt, all builds, all The only two failing checks are human-gated and can't be resolved by a push:
|
|
@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 has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/carlosmiceli in version: 9.4.54-0 🚀
|
|
I reviewed the changes in this PR against the help site articles under Why: This PR is an internal bug fix to a default value in the assign-company-card flow — the auto-generated default card name ( 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 |
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
customCardNamegets 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:Single active-employee shortcut picked the wrong email. In
useInitialAssignCardStep(src/hooks/useAssignCard.ts), thelength === 1check ran on the filtered (non-deleted) employee list, butuserEmailwas read fromObject.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.Stale guards never recomputed the name when the assignee changed.
AssigneeSteponly setcustomCardNamewhen 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 inCardNameStep(tracked with a newisCustomCardNameEditedflag).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
<selected employee>'s card(not the admin's).Offline tests
Same as tests.
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari