The scandal engulfing Puerto Rico was most recently fueled by revelations in July that Gov. Richard Rosselló had exchanged sexist and homophobic messages with top aides — but the seeds of citizens’ discontent had been sown years earlier.

The US territory is drowning in debt to the tune of roughly $70 billion, with roughly 40 percent of island residents living in poverty while government spending is out of control.

Puerto Rico defaulted on its monthly debt for the first time in 2015. Two years later, the territory filed for bankruptcy — the largest US bankruptcy claim for a government entity in history.

And as the economy gets worse, more Puerto Ricans leave the island, meaning the government has less tax revenue to pay the bills.

Hurricane Maria made everything worse.

The 2017 storm killed more than 3,000 people, knocked out power for months and devastated the island’s housing stock and infrastructure. It also created a feud between President Trump and some Puerto Rican officials, who complained about what they called the administration’s lackluster response to the tragedy.

Then, with recovery efforts ongoing, Puerto Rico’s Center for Investigative Journalism released 900 pages of leaked chats in which Rosselló and a dozen aides and Cabinet members exchanged the nasty messages about rivals, celebrities and others, in a scandal wags dubbed “RickyLeaks.”