Check for length of messages array before displaying a popup