Mila Kunis and Kate McKinnon who are the lead actresses of this movie were announced back in March. Gillian was announced to be part of it at the same time as Justin Theroux, so I don’t think their roles were added last minute, that doesn’t seem possible to me. Things like that might be planned a few months in advance, at least. It’s possible she was cast not long ago, though. If I remember correctly, back in March, she said during an interview that she didn’t have any project at the moment, and would use some free time. So maybe she didn’t know at that time, or maybe she did and couldn’t talk about it, we will never know. But her role definitely hasn’t just been written for her.