In general, it is best to avoid wearing a hat to a viewing unless you are certain that it is acceptable to do so. It is important to be respectful and considerate of the family's wishes and cultural or religious traditions.