The purpose of this hook is to take in a UserInfo and return a UserProfileThreadInfo. A UserProfileThreadInfo is an object that contains a PERSONAL and PRIVATE threadInfo and an optional pendingPersonalThreadUserInfo. Both of these are needed for the navigateToThread hook (for navigating to the thread between the viewer and the user in the profile) and the useRelationshipPrompt hook (for doing relationship actions like friending, unfriending, blocking etc. between the viewer and the user in the profile).
The hook first selects all the PERSONAL and PRIVATE threads from the thread store using the threadInfosSelectorForThreadType selector introduced in D9204 since these are the only relevant thread infos for user profiles. Then the hook checks if the userID passed through the userInfo is the same userID as the logged in user. If it is we just return the PRIVATE thread info.
If the userID is in usersWithPersonalThread (a set of userIDs that the logged in user has personal threads with) then we iterate through the personal thread infos until we find the case where the userID matches the other single user of that personal thread and return that threadInfo
Otherwise if no thread exists, we create a pending personal thread using the createPendingPersonalThread function which is introduced in D9235 and return that (this pending personal thread will include a threadInfo and a pendingPersonalThreadUserInfo).
Depends on D9204