We don't always know about every user id. So, our code should
reflect the same.
Fixed by refactoring the function to use User object a function
parameter and let the called get the user object if possible.
This reduces duplicate calculation to get user object too.
There's a rare possibility for a user to have no last_active_time. In
such a case, we always want to fall back to date_joined for displaying
"Last active" in the UI.
Co-authored-by: Tim Abbott <tabbott@zulip.com>
In the right side-bar, the popover states "Active x minutes ago",
even though the user could have been idle before going offline.
In that case we are stating something false, as the user was not
"Active x minutes ago", they were "Idle x minutes ago". Always
prioritizing the active_timestamp if possbile rather than taking
the max of active_timestamp and idle_timestamp fixes this issue.