Spell levels in contexts outside of actually casting are ambiguous. This is what allows some shenanigans when you can, say, choose to learn any 1st-level spell, as some prestige classes allow – and you pick 1st-level haste off of the trapsmith spell list. The trapsmith is a prestige class from Dungeonscape that has a specialized spell list of only 1st to 3rd level spells, but gets some spells at much lower levels than normal.
But bypassing spell immunity, once it’s up, is not that situation. When a spell interacts with spell immunity, it is being cast. When it’s being cast, it is being cast by a particular person, who knows that particular spell, from a particular class, at a particular spell level.
So whether or not you can pick dominate person is ambiguous, for the same reason that it’s uncertain if you can pick haste as a 1st-level spell because of trapsmith. But assuming you can (and most do assume you can, if for no other reason than because it becomes very difficult to clearly define what a spell’s level is “supposed to be” “normally” in these situations), then, if you buy d7’s argument that the limitation is only on selecting the spell, then you are immune to dominate person even when cast as a 5th-level spell.
However, I’m not sure that his argument is valid. The statement is only that “The spells must be of 4th level or lower.” That’s quite broad, and could apply to both choosing and to the immunity. If that is the case, then you would be immune to a bard’s dominate person but not a sorcerer or wizard’s.
Ultimately, the question of what that line in spell immunity refers to is ambiguous; it should be errata’d by Paizo, but that almost certainly won’t happen. So you’ll have to ask your DM.