SPOILER ALERT: Do not read if you have not yet watched “I Want to be Here,” the fourth season premiere of “Crazy Ex-Girlfriend.”

The final season of “Crazy Ex-Girlfriend” started with Rebecca Bunch (Rachel Bloom) in prison after shoving her stalker ex Trent (Paul Welsh) off of a rooftop. She went into prison willingly, as an attempt to finally own up to her actions, but the experience was not at all what she expected.

“The key thing that we discussed was that in Rebecca Bunch fashion, the thing she does at the end of the third season is well-intentioned but totally wrong. She wants to take responsibility, which is great and to be applauded, but pleading guilty to something you’re not legally liable for and volunteering to go to prison is not very bright,” showrunner Alish Brosh McKenna tells Variety. “She has a flair for the dramatic, so she had a romantic idea of what she was doing, but once she gets in there, she realizes there’s nothing glamorous about it.”

Rebecca’s time in prison proved to be short-lived, because Trent admitted to stalking Rebecca and trying to kill Nathaniel (Scott Michael Foster), proving she was only acting in defense of Nathaniel. But being in prison opened her eyes to her privileged worldview, so the rest of the series will focus on her finding truer ways to be a better person and atone.

“A lot of the things that she does and the ways that she’s behaved in general in the series are connected to the fact that she’s lived a very privileged existence by way of her background and her intelligence and the money she made as a young person, so she has kind of a skewed view of the world, and this is an eye-opening experience for her,” McKenna says. “She has a long way to go.”

Here, McKenna talks with Variety about the rough road still ahead for Rebecca, what it means for her relationships with Nathaniel and Josh, and why she chose the premiere to make her cameo appearance.

Was it ever a question that Rebecca would only be in jail for one episode?

Here’s the thing: She really is not liable because she’s trying to save Nathaniel. But because Trent got a job as a carver, he did that so he could have a knife in his hand, credibly. But really we wanted to take the onus off the legal case against her and focus on her own sense of what penance she needs to pay. And you can’t stay in prison if there are no charges against you, but she is also trying to hide out from the world, and she’s trying to take responsibility, but she doesn’t really know how to do that, and that plays out in the rest of the season.

Trent was such an integral part of Rebecca’s journey and her struggles at the end of the third season, but does ending the fourth season premiere with him awakening from his coma mean his and Rebecca’s stories are still intertwined?

Not at all. Trent is more from the metaphorical part of the show and he represents a part of her, and also he’s the one who set her up to be in this situation, and then he’s also the person who can easily exonerate her. … [Also] Trent actually used to be in the [third season premiere opening] song. That’s why there’s some errant photos floating around of Paul dressed as a knight. He was in the song, too, but there was so much plot to catch for the audience to catch up on, and we’re always thinking about if you’ve never seen the show, you don’t want to be locked out of a song. So Trent was the piece — you couldn’t figure out who Trent was just from context. Some of the footage we shot of Trent not as knight but just as Trent we used later in the season, in episode 12 — like the shot of him getting hit by a bus.

How has what Rebecca has learned from her time in prison going to be added to what she has learned about herself and her borderline personality disorder to see changes in her behavior?

She’s sort of desperate. She’s on this journey towards trying to take responsibility, and she realizes pretty quickly the idea she has to try and take these women’s stories and try and turn it into some cool PBS thing is pretty bad, and she’s grasping at straws trying to figure out, “What am I supposed to do here and if I get out what am I supposed to do?” … She knows now what she has and she has several kinds of treatment. She knows, “OK I’m doing this — these are hallmarks of my illness.” But just because you’re aware of it [now] doesn’t mean you’re not doing it anymore now at all. That’s really the struggle. She’s always trying to remind herself of the steps she can take to mitigate her illness through various techniques, but it doesn’t mean she’s not going to make mistakes.

When Rebecca received her BPD diagnosis you talked about the research that went into carefully depicting it. What discussions did you have around how to balance the care and comedy of Josh (Vincent Rodriguez III) hoping he could be diagnosed with something?

We went through a couple of tests to try and diagnose what we thought Josh Chan might be — we did exactly what the therapist says not to do. And because we are in a culture where people are seeking those kinds of answers sometimes in a way that isn’t quite earnest, he sees that she has something to work on and he’s inspired by her. But then he finds out that he has the more garden variety issues that other people have and he has to learn how to be introspective and thoughtful and a bunch of things that he hasn’t been yet. … That’s a series-wide thing. People find out information about themselves and they gain insights, but just because you consciously know something about yourself doesn’t mean you’ll be able to eradicate those behaviors from your life.

Structurally, is it easier to work Rebecca and Josh back into scenes together now that he is on a path to bettering himself, too?

This is a story where he’s inspired by her and we’re just as interested in the other characters as we are Rebecca, and they are still very connected. They do become closer during the season, and they have a natural affinity for each other and a natural history, so we still love writing scenes for them that bring them together.

Where does this leave Nathaniel? At the end of the premiere he seemed to just want things to get back to the way they were before Rebecca went to jail, but she has evolved a bit beyond that.

That’s the kind of struggle for him this season because he was happy when he was with her, partly because she enabled him to deal with his emotional issues and he doesn’t really know how to deal with them without her. She’s his touchstone. So he needs to learn how to express himself emotionally without her…and then he also has to confront some things about himself, which is he isn’t the best guy morally and he makes some poor decisions morally. He’s probably behind everybody else. I mean, he’s behind Josh at this point! So he’s probably two seasons behind Rebecca and a season behind Josh because Josh is actually [now] trying to understand who he is and what his purpose is.

Rebecca lit up as much, if not more, playing those theater games in prison than she has in the relationships we’ve seen her in thus far. Is the next step for her to acknowledge how much she needs an outlet into which to channel some of her obsession?

It really seems it. We have some storylines that continue to deal with her love and attraction for music and theater. [The group is] going to do theater without her, and we do actually check back in on them. She continues to work on that program for the rest of the season — the series — but she’ll help them with legal stuff, not the show. There are so many people, so many relationships, dealing with what she wants to do with her life and who she wants to spend time with — a lot of things before she turns attention back to romance.

You also appeared in the episode as the prosecutor in the state’s case against Rebecca. What made this character the right one to take on?

Rachel is my stage mom and has been insisting that I be in an episode. Also, my husband and my kids also thought it would be fun for posterity. We had talked a little bit about what character I could play, and it seemed funny for me to be a person who’s mean to her and wants her to go to prison and isn’t very sympathetic. It just made us giggle.

“Crazy Ex-Girlfriend” airs Fridays at 9 p.m. on the CW.