I believe magic immune units cannot be targeted with spells regardless of the target allowed settings.
A workaround is to make the ability an ultimate. To do this, create a custom ability that you want. Make it a hero ability. Set 'Required level' to 6. Then change the ability back to unit ability. And give it to your unit. It should be able to cast on magic immune units now. This is for unit abilities though. If you want to use the ability as a hero ability, then you may need to use the dummy method.