Hide attachments in history if user can't see them

If user is not allowed to view attachments (i.e. their access level is
lower than $g_view_attachments_threshold), then the history should not
display information about attachments.

Fixes #17744

Backported from master (c2e2bf1c614afe2e3b0739c789f85413d4ef29cd)