diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -114,6 +114,7 @@ entityTextToRawString, getEntityTextAsString, type ThreadEntity, + type UserEntity, } from '../utils/entity-text.js'; import { useSelector } from '../utils/redux-utils.js'; import { firstLine } from '../utils/string-utils.js'; @@ -935,16 +936,26 @@ return rawThreadInfo; } -function threadUIName(threadInfo: ThreadInfo): string | ThreadEntity { +function threadUIName( + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +): string | ThreadEntity { if (threadInfo.name) { return firstLine(threadInfo.name); } - const threadMembers = threadInfo.members.filter( - memberInfo => memberInfo.role, - ); - const memberEntities = threadMembers.map(member => - ET.user({ userInfo: member }), - ); + + let threadMembers: + | $ReadOnlyArray + | $ReadOnlyArray; + let memberEntities: $ReadOnlyArray; + // Branching below is to appease flow + if (threadInfo.minimallyEncoded) { + threadMembers = threadInfo.members.filter(memberInfo => memberInfo.role); + memberEntities = threadMembers.map(member => ET.user({ userInfo: member })); + } else { + threadMembers = threadInfo.members.filter(memberInfo => memberInfo.role); + memberEntities = threadMembers.map(member => ET.user({ userInfo: member })); + } + return { type: 'thread', id: threadInfo.id, diff --git a/lib/utils/entity-text.js b/lib/utils/entity-text.js --- a/lib/utils/entity-text.js +++ b/lib/utils/entity-text.js @@ -17,7 +17,7 @@ import { type RawThreadInfo, type ThreadInfo } from '../types/thread-types.js'; import { basePluralize } from '../utils/text-utils.js'; -type UserEntity = { +export type UserEntity = { +type: 'user', +id: string, +username?: ?string,