SPOILER ALERT: Do not read if you have not yet watched the Nov. 17 episode of “Crazy Ex-Girlfriend,” entitled “Josh Is Irrelevant.”

Until now on “Crazy Ex-Girlfriend,” Rebecca Bunch (Rachel Bloom) thought she suffered with anxiety, depression, and OCD. But in the sixth episode, she received a new diagnosis: borderline personality disorder (BPD).

“We wrote her kind of by feel for a while,” explains executive producer Aline Brosh McKenna. “We kind of wrote her behavior in a way that felt right to us for about a season and a half, and then Rachel and I started to realize this was an area we were going into. It’s funny, we were trying to help Rebecca, so we were trying to figure out what was best for her. And when we looked into it, so much of this seemed to resonate.”

After attempting to commit suicide, Rebecca was admitted to a hospital where her doctors discovered that she ticked more than just the five items on the BPD checklist necessary for the diagnosis.

In fact, when McKenna was researching the disorder, she realized that not only did Rebecca exhibit all nine of the items on the list, but in their 36 episodes, they had about 10 examples of each of the nine symptoms.

“No diagnosis is a perfect diagnosis, and it’s a bit imprecise, and there are many schools of thought on BPD, but we tried to dial in on what we thought was accurate for her,” McKenna says.

Rebecca was initially excited to learn her previous diagnoses were inaccurate, which led to a musical number about finding her “tribe” and understanding what was wrong so it could be fixed. But when she received the actual diagnosis, her tune changed because she thought it meant she was “broken” and would not be able to be fixed after all.

“There are a whole host of behaviors that are deeply rooted in her, so she’ll continue to struggle — but she’ll struggle with more information,” McKenna says.

Now that she has an official diagnosis, that struggle will be “to include her new truths about herself into her daily life,” says McKenna, as well as to learn new strategies to try and get better. For Rebecca, the path will be “intensive” therapy, which the show will explore in upcoming episodes through group therapy sessions.

“Mainly it’s a lot of hard work, and it’s really challenging, and the people who do that hard work are very brave,” McKenna says. “Just because she has a name for it, it doesn’t mean her behavior’s going to be different. In many ways, it kind of enhances her struggle, it makes it harder. Because now when she’s doing things, she knows why, and that makes her confused and angry. And there’s a lot with mental health stuff [that’s] one step forward and two steps back. She’s not always diligent about it, but we really see her going forward, doing the work. She really is an A-student, so when she has an assignment she really takes it on.”

By the end of the episode, Rebecca also finally acknowledged that her ex Josh (Vincent Rodriguez III) was not the cause of her problems.

“For Rebecca, love is her drug of choice,” McKenna says. “That’s a very dangerous substance, but like food, you need to have it. So she has to learn how to get love in her life in a healthy way, which is obviously very challenging for her. And if she messes up with that going forward, it has possible serious consequences for her.”

As Rebecca struggles to come to terms with her diagnosis (“Is that who I am? How do I live within that? What choices do I make now?” says McKenna) she isn’t the only one who is going to have to do some hard work to understand their own psychology. Nathaniel (Scott Michael Foster) finally got a glimpse into his family’s history when he learned his mother overdosed on sleeping pills when he was a child. Despite that backstory, McKenna says, it won’t always be easy for him to see what Rebecca is going through.

“He’s got a lot of unresolved pain in his past,” McKenna says. “It sets him on the most serious of the journeys.”

Josh, too, must figure out who he is and what he wants his life to be without a relationship with Rebecca.

“What I think is really interesting is that Josh had connected to her because he was struggling with his own identity and failing in New York, and here’s this smart, cosmopolitan, charming, beautiful girl that loves [him] and makes [him] feel special,” McKenna says. “Of course the audience has always known that it had nothing to do with him – he was just kind of conveniently placed – but he didn’t know that. He thought she loved him, and that made him feel great. He really starts to have his quarter-life crisis now. He is now unemployed, he doesn’t have a place to live, he doesn’t have her anymore, he’s not seeing anyone. It’s tough stuff coming up for Josh.”

The season may have started off as a revenge tale, but it has grown into something much more complicated. That’s why, although McKenna originally considered the “Scary Scary Sexy Lady” song as a new opening credits sequence, they ultimately went with “Crazy” instead. And similarly, McKenna admits that “there’s a change in the names in the episode titles coming up” to cover the new themes – and really, new Rebecca – with which the show is now dealing.

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