A number of effects in D&D 5e can change a creature's hit point maximum. Some issues in the specifics of how some features are written can arise when these effects coexist or otherwise interact.
All emphasis mine. From the description of the druid's Wild Shape feature (PHB p. 64):
- Your game statistics are replaced by the statistics of the beast, but you retain [some non–hit-point-related statistics].
- When you transform, you assume the beast's hit points and Hit Dice. When you revert to your normal form, you return to the number of hit points you had before you transform.
An important note is that the latter bullet point refers to current hit points, not hit point maximum, as per PHB p. 196:
A creature's current hit points (usually just called hit points)...
Similarly, from the polymorph spell description (PHB p. 226) and the Creature into Creature section of the true polymorph spell description (PHB p. 283):
The target's game statistics, including mental ability scores, are replaced by the statistics of the chosen beast. It retains its alignment and personality.
Finally, from the description of the spell aid (PHB p. 211):
Each target's hit point maximum and current hit points increase by 5 for the duration.
It appears unclear how the change to a creature's hit point maximum via the aid spell interacts with the change caused by the other listed features—especially when this happens multiple times. This raises an issue of interpretation which comprises two sub-questions.
Part 1: aid → transformation → aid ends
If aid is cast on a creature who then is affected by an effect such as Wild Shape which changes its hit point maximum in this way, what happens when the aid spell ends before the transformation effect?
- The (transformed) creature's hit point maximum decreases by 5 (to 5 less than the hit point maximum of the target form without the effect of the aid spell)
- The (transformed) creature's hit point maximum does not change
- The (transformed) creature's hit point maximum decreases by 5 (to the hit point maximum of the target form without the effect of the aid spell)
Part 2: above transformation ends
Continuing from the previous situation, when the creature reverts to its previous/original form (after aid has already ended), what is its hit point maximum?
- The creature's hit point maximum is the hit point maximum it had before it transformed
- The creature's hit point maximum is the hit point maximum it had before the effect of the aid spell
It is likely that the answer to one of these questions will determine the other according to the accompanying reasoning, but it seems best to present both questions to allow for different approaches to the problem and a larger set of relevant rules to answer the situation as a whole.
An accepted answer will attempt to interpret the rules in plain English while putting no weight on separate considerations such as lore, flavour, or game balance and provide its reasoning as such. This is because the answer would otherwise be highly opinion-based (in the case of lore or flavour) or, at least for the latter sub-question, trivial to answer. Please also note if (and why) the answers would be different for the listed transformation effects.