The spell aid temporarily raises a target's hit points and maximum hit points by 5:
Each target's hit point maximum and current hit points increase by 5 for the duration.
A vampire's bite, for instance, causes necrotic damage with a rider that reduces the victim's maximum hit points:
The target's hit point maximum is reduced by an amount equal to the necrotic damage taken
If a character under the effect of aid is bitten by a vampire (or subject to any other effect that reduces their maximum hit points), what happens to their maximum hit point total when aid subsequently expires or is dispelled? I can see two interpretations:
The character's maximum hit points drop by 5 again, so ultimately their new maximum hit point total is whatever it would normally be less the maximum hit point reduction they suffered
The maximum hit point loss suffered reduces the increase granted by aid first, and maximum hit points already lost this way aren't lost again when aid ends, so the character is up to 5 points better off than they would have been without aid
Essentially, aid might or might not act as a buffer against maximum HP loss after it expires, but I'm not sure which interpretation is best supported by the rules.