“Roseanne” was TV’s most-watched show this year . . . but yesterday, ABC canceled it after ROSEANNE BARR posted a racist Tweet about former Obama adviser Valerie Jarrett, who’s African American.

She Tweeted, quote, “Muslim Brotherhood and ‘Planet of the Apes’ had a baby [equals] VJ.”

Apparently, she thought it was funny, but even she realized that she crossed a line . . . AFTER she found out she was in trouble.

A few hours later, she Tweeted, quote, “I’m now leaving Twitter . . . I apologize to Valerie Jarrett and to all Americans.  I’m truly sorry for making a bad joke about her politics and her looks.  I should’ve known better.  Forgive me, my joke was in bad taste.”

Valerie seems like a random target . . . but Roseanne Tweets about conspiracy theories a lot, and in this case she was responding to a Tweet alleging that Valerie helped “hide” various Obama-era secrets.

ABC wasted no time in firing her.  Three hours after her apology, the network said, quote, “Roseanne’s Twitter statement is abhorrent, repugnant, and inconsistent with our values, and we’ve decided to cancel her show.”

ABC is owned by Disney, and they weren’t having it.  Disney CEO Bob Iger Tweeted, quote, “There was only one thing to do here, and that was the right thing.”  He also said, quote, “You can’t debate what is morally right.”

On top of everything else, this wasn’t the first time Roseanne compared an African-American to an ape.  (CAREFUL!)  In 2013, she called Obama’s National Security Adviser Susan Rice a, quote, “man with big swinging ape [testicles].”

For the record, Valerie is not Muslim and is not a member of the Muslim Brotherhood . . . not that it should matter to anyone.  She was born in Iran in 1956, but her parents are Americans.  Her father was there running a hospital for children.

Yesterday, Valerie responded, quote, “We have to turn it into a teaching moment.  I’m fine.  I’m worried about all the people out there who don’t have a circle of friends and followers coming to their defense.”

Roseanne didn’t just lose her show.  She was also dropped by her agency, ICM Partners, which called the Tweet “disgraceful and unacceptable.”  And ABC has scrapped its Emmy promotion on behalf of the show.

Meanwhile, “Roseanne” is disappearing everywhere, Hulu dropped it . . . and the Paramount Network, TV Land, and CMT have pulled their scheduled re-runs.