Skip to content

fix(b2b): show learner email and icon avatar when name is blank - #3992

Merged
daniellefrappier18 merged 3 commits into
mainfrom
daniellef/fix-learner-with-null-name
Sep 30, 2026
Merged

daniellefrappier18 merged 3 commits into
mainfrom
daniellef/fix-learner-with-null-name

Conversation

@daniellefrappier18

@daniellefrappier18 daniellefrappier18 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

Follow-up to #3958

Description (What does it do?)

Fix blank learner names on the B2B contract learner directory (/organization/:orgSlug/contract/:contractSlug/learners).

In prod, many rows show a "?" avatar and no name, with only the course title. LearnerRow used row.full_name ?? row.email, and ?? only falls back on null or undefined. A null name would have fallen back to the email, so the blank rows mean full_name is "" or whitespace.

  • Treat null, empty, and whitespace-only names as missing (row.full_name?.trim() || null), and skip the name line when there's no name
  • Always show the learner's email between the name and the course title
  • Show a generic person icon (RiUserLine) instead of "?" when there's no name. "?" reads as an error, and initials taken from an email are wrong for addresses like jdoe@ or x7k2m@. The avatar stays aria-hidden.

Companion PR: mitodl/ol-analytics-api#71 returns blank names as null, so they stop sorting ahead of every real name on page 1.

Implementation details
  • The "Unknown learner" fallback is gone. The email now shows in its own line, so there's nothing left to fall back to.
  • The commented-out row checkbox's aria-label now falls back to name ?? row.email, so turning that block back on can't produce "Select null".
  • A row with neither a name nor an email shows only the icon and the course title.

Screenshots (if appropriate):

  • Desktop screenshots
  • Mobile width screenshots

BEFORE
Screenshot 2026-09-25 at 9 33 20 AM

AFTER
Screenshot 2026-09-25 at 9 33 26 AM

How can this be tested?

Automated: yarn test frontends/main/src/app-pages/ContractLearnersPage. New tests cover name + email + initials, and null, "", and whitespace-only names (email shown, icon avatar, no "?").

Locally, with the analytics-api stub from mitodl/ol-infrastructure#5788. You don't need mitodl/ol-analytics-api#71: local dev uses the stub in place of the real API, and this change doesn't depend on the sort order.

  1. Set up the stub by following the "How to use it" steps in ol-infrastructure#5788. The stub includes three learners with no usable name:

    full_name Email
    null x7k2m@example.edu
    "" jdoe@example.edu
    " " sso.user.4471@example.edu
  2. Open a contract's learner directory at /organization/<orgSlug>/contract/<contractSlug>/learners. The stub answers every contract with the same data.

  3. At the top of page 1, the "" and " " rows show a person icon, the email, and the course title. There's no "?" and no empty name line. The null rows show the same way at the end of page 2.

  4. Named learners still show initials, name, email, and course title.

  5. Search for jdoe or x7k2m to find those rows.

Additional Context

  • Until ol-analytics-api#71 ships, blank-name rows still sort to the top of page 1. They now render correctly.

🤖 Generated with Claude Code

The learner-progress API returns full_name as "" (not null) for learners
who never set a profile name. LearnerRow's `??` fallback only caught
null, so those rows rendered an empty name and a "?" avatar.

- Treat null, empty, and whitespace-only names as missing
- Always show the learner's email under the name
- Show a generic person icon instead of "?" when there is no name

Follow-up to #3958.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

OpenAPI Changes

No changes detected

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The runtime changes are correct and tested; the remaining comment concerns only dormant checkbox code.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes blank learner identities in the B2B contract learner directory.

Changes:

  • Normalizes blank names and shows email separately.
  • Uses a generic avatar icon when names are unavailable.
  • Adds coverage for null, empty, and whitespace-only names.
File Description
LearnerRow.tsx Updates learner identity and avatar rendering.
ContractLearnersPage.test.tsx Tests named and unnamed learner rows.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread frontends/main/src/app-pages/ContractLearnersPage/LearnerRow.tsx Outdated
daniellefrappier18 and others added 2 commits September 25, 2026 10:07
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ahtesham-quraish ahtesham-quraish self-assigned this Sep 30, 2026

@ahtesham-quraish ahtesham-quraish 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.

LGTM!

@daniellefrappier18
daniellefrappier18 merged commit 41ceacf into main Sep 30, 2026
14 checks passed
@daniellefrappier18
daniellefrappier18 deleted the daniellef/fix-learner-with-null-name branch September 30, 2026 12:48
@odlbot odlbot mentioned this pull request Sep 30, 2026
6 tasks done
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.

3 participants