Both the films have been classified as adapted works

When talking about writing the screenplay for Moonlight, filmmaker Barry Jenkins told The Times recently that there’s no way he could have made the movie without Tarell Alvin McCraney’s unproduced play, In Moonlight Black Boys Look Blue, as a starting point.
“Tarell’s voice is crucial to the piece,” Jenkins said.
It turns out that the Academy of Motion Picture Arts and Sciences agrees, ruling that Jenkins’ Moonlight screenplay is an adapted work, a development first reported by Deadline. The film’s distributor, A24, had been campaigning the work as an original screenplay going by the Writers Guild of America’s classification of the movie made months ago.
The academy also classified Jeff Nichols’ screenplay for his civil rights drama Loving as an adapted work, determining that it originated from the 2011 HBO documentary, The Loving Story. Focus Features has been campaigning Nichols’ work for original screenplay, again, going by the previous Writers Guild designation.
This kind of Oscar category confusion has happened to other screenplays over the years, most recently to Damien Chazelle’s 2014 film Whiplash. The motion picture academy ruled that Chazelle’s screenplay had been adapted from a short film he made to secure financing for the Whiplash feature. Never mind that no one saw the short, outside of would-be financial backers.
Stephen Gaghan’s Syriana saw a different kind of reversal in 2005. The political-thriller earned a WGA nod as an adapted screenplay, based on Robert Baer’s book See No Evil, and picked up similar recognition from the National Society of Film Critics and USC’s Scripter Awards. But, in a surprise, the academy decreed that Gaghan’s script was significantly different from Baer’s work and classified it as an original screenplay.
This year’s shuffling opens up spots in the original screenplay category, where Moonlight, along with Manchester by the Sea, had been considered favourites.