Has any research in animals (non human) shown headaches or bad dreams?
Dogs growl in their sleep sometimes, which suggests that they are dreaming about something that they don’t like. There is also a famous study of cats whose brains had been operated upon to remove the inhibition of movements during sleep. The cats, in effect, acted out their dreams (IIRC they eventually died of exhaustion), and I believe the stuff acted out sometimes included fear and anger behaviors. (See this book, although I believe the original experiments were done, by that author, very much earlier. Here is a brief video here of a dreaming, unparalysed cat.)
Beyond that sort of level, this sort of thing is going to be very difficult to research, because we generally only know about people’s nightmares and headaches when they tell us about them. I believe the immediate causes of most headaches are certain patterns of tension in the muscles of the head, and one might be able to look for homologous tensions in animals (and perhaps correlate them with grumpy behavior), and from that infer that they are quite likely suffering from a headache, but that would only be a start, and rather a shaky one.
Well I’m sure if you ask any dog owner they can recall seeing vocalizations and movements that indicate both anger and fear(along with joy and excitement) in their sleeping dogs. I don’t know how that could be anything except dreaming.