most of this function comes from the previous function `ThreadUI.renderContact`. I think we can do better (especially have more functions instead of one big function) but it will be easier to change now that it's in a separate file.