Repository: freeCodeCamp/freeCodeCamp
File: api/src/routes/public/user.ts (TypeScript)

Code before:
        'sendQuincyEmail',
        'theme',
        // keyboardShortcuts is included in flags.
        // 'keyboardShortcuts',
        'acceptedPrivacyTerms',
        'progressTimestamps',
        'unsubscribeId',
        'donationEmails',
        'externalId',
        'isBanned'
      ]);

      const normalizedProfileUI = normalizeProfileUI(user.profileUI);

      void reply.code(200);
      if (normalizedProfileUI.isLocked) {
        // TODO(Post-MVP): just return isLocked: true and either a null user
        // or no user at all. (see other TODO in the else branch below)
        return reply.send({
          entities: {
            user: {
              [user.username]: {
                isLocked: true,
                profileUI: normalizedProfileUI,
                username: user.username,
                usernameDisplay: user.usernameDisplay
              }
            }
          },
          result: user.username
        });
      } else {
        const progressTimestamps = user.progressTimestamps as
          | ProgressTimestamp[]
          | null;
        const sharedUser = replacePrivateData({
          ...user,
          calendar: getCalendar(progressTimestamps),
          completedChallenges: normalizeChallenges(user.completedChallenges),
          location: user.location ?? '',
          joinDate: new ObjectId(user.id).getTimestamp().toISOString(),
          name: user.name ?? '',
          points: getPoints(progressTimestamps),
          profileUI: normalizedProfileUI
        });

        const returnedUser = {
          ...removeNulls(publicUser),
          ...normalizeFlags(flags),
          ...sharedUser,
          picture: user.picture ?? '',

Review comment (suggestion):
```suggestion
                usernameDisplay: user.usernameDisplay || user.username,
```

Code after:
        'sendQuincyEmail',
        'theme',
        // keyboardShortcuts is included in flags.
        // 'keyboardShortcuts',
        'acceptedPrivacyTerms',
        'progressTimestamps',
        'unsubscribeId',
        'donationEmails',
        'externalId',
        'isBanned'
      ]);

      const normalizedProfileUI = normalizeProfileUI(user.profileUI);

      void reply.code(200);
      if (normalizedProfileUI.isLocked) {
        // TODO(Post-MVP): just return isLocked: true and either a null user
        // or no user at all. (see other TODO in the else branch below)
        return reply.send({
          entities: {
            user: {
              [user.username]: {
                isLocked: true,
                profileUI: normalizedProfileUI,
                username: user.username,
                usernameDisplay: user.usernameDisplay || user.username
              }
            }
          },
          result: user.username
        });
      } else {
        const progressTimestamps = user.progressTimestamps as
          | ProgressTimestamp[]
          | null;
        const sharedUser = replacePrivateData({
          ...user,
          calendar: getCalendar(progressTimestamps),
          completedChallenges: normalizeChallenges(user.completedChallenges),
          location: user.location ?? '',
          joinDate: new ObjectId(user.id).getTimestamp().toISOString(),
          name: user.name ?? '',
          points: getPoints(progressTimestamps),
          profileUI: normalizedProfileUI
        });

        const returnedUser = {
          ...removeNulls(publicUser),
          ...normalizeFlags(flags),
          ...sharedUser,
          picture: user.picture ?? '',