Joan Rivers was in talks to star in a new TV sitcom at the time of her unexpected death.

The legendary comic and “Fashion Police” host agreed to headline the show just 24 hours before undergoing a fatal botched surgery in August 2014, comedy writer Nick Malis revealed on the new web series “Pizza with Writers.”

Malis — the executive producer of Comedy Central’s “Tosh.0” — pitched the untitled project which was being developed by Imagine Entertainment.

“She loved the idea,” Malis told host Jon Hotchkiss. “She wanted to do it. Her agent called me right after the meeting.”

Malis — who began his career writing jokes for Rivers — says she would have portrayed a popular fashion magazine editor (think Anna Wintour) who falls on hard times when her publication folds.

More On This...

“[The character] wasn’t good with money, so all she has to her name is this brownstone in Manhattan,” he tells FOX411.  

“She was a former queen of Manhattan and now she is broke and she is forced to rent out her brownstone Airbnb style.”

Hours after hearing the pitch, Rivers flew back to New York.The following day fell into a coma during a routine throat procedure.

Rivers, whose show business career spanned more than six decades, died September 4, 2014 from brain damage caused by lack of oxygen. She was 81.

“Her agent called me the day she died and said, ‘That was the last meeting I ever had with Joan. The last meeting Joan ever had,” Mallis reveals on the show.

“[Her agent said], ‘She died being really hopeful about this project. It is what she wanted to do.’”  

“So I had the last meeting with Joan. Maybe it was a lie and she hated the project… but I don’t think so.”

“Pizza with Writers” features intimate conversations between Hotchkiss, a 14 time Emmy nominee, and the creative voices behind some of TV’s most popular programs.  

Upcoming guests include Jay Krogen (“The Simpsons”), Tess Rafferty (@midnight) and Marc Guggenheim (“Arrow”).