When Barack Obama won the presidency in 2008, the nation was in economic collapse, embroiled in wars abroad, and suffering a crisis of self-confidence not seen since the 1970s. The Onion, insightful as always, had the perfect headline for the situation: "Black Man Given Nation's Worst Job."

"As part of his duties," the satirical news organization reported, "the black man will have to spend four to eight years cleaning up the messes other people left behind."

Democrats take control of the House of Representatives next week, with Nancy Pelosi (Calif.) reclaiming the title of speaker of the House for the first time since the 2010 midterm elections. Given the chaos of the moment, you wouldn't blame The Onion for recycling its old headline, with a twist: "Woman Forced to Clean Up Messes Men Left Behind."

Let's consider what Pelosi and House Democrats are likely to face when they take power:

A government still shut down because President Trump can't get the votes he needs for border wall funding. House Republicans, who control the chamber through the end of the year, this week signaled there will be no more votes to end the shutdown until Democrats take over — ending an era of ineffectual GOP control on an appropriate note.

The structural problems of a massive debt and deficit created by Republicans who have spent the last generation delivering tax cuts to wealthy supporters with little-to-no apparent consideration for the continued operation of government services.

An executive branch mired in disarray, scandal, and legal troubles, led by an over-his-head reality show star with a penchant for making mischief.

Democrats face all of that — plus, oh yeah, they have an agenda of their own they want to pursue.

That they find themselves in this position is not a surprise. Since the Nixon era, the country has consistently asked Democrats to step in when Republicans have proved too corrupt or too incompetent to manage the nation's affairs: Jimmy Carter became president in the aftermath of Watergate; Bill Clinton won the presidency after the nation slipped into recession under George H.W. Bush; Pelosi became speaker the first time after Hurricane Katrina and the disastrous war in Iraq made George W. Bush's failings manifest; and Obama became president when the world economy appeared to be headed toward collapse.

Republicans make messes. Democrats, for better and for worse, try to clean them up.

The challenge, as always, will be balance: How can Democrats pursue their own agenda while at the same time trying to repair the damage done by their Republican rivals? There's only so much political energy to go around, and prioritizing some issues means others will fall to the wayside.

This was certainly true for Obama. Any agenda he had was effectively put on hold by the burgeoning Great Recession taking hold of the country when he arrived in office. That required him to spend political capital building and passing an economic stimulus bill, while taking extraordinary steps to bail out a domestic automotive industry that was on the cusp of collapse. Stuff that went undone: Any attempt to hold banking and finance companies accountable for their roles in breaking the economy, along with any effort to hold Bush-era officials accountable for torture and other excesses during the War on Terror.

Obama still receives criticism for those shortcomings, but it's possible, even likely, that a legal crusade against the villains of his predecessor's era might have made it impossible for Democrats to pass the Affordable Care Act — which initially proved unpopular, but has grown in the public's esteem the more Republicans have tried to undermine it.

Would you rather have access to health insurance, or see Bush-era torture advocates behind bars? In a perfect world, you could have both. Realistically, Democrats had to make choices, and they will again.

Among their current priorities: restoring key provisions of the Voting Rights Act, reducing the cost of prescription drugs, and an anti-corruption bill intended to reduce the influence of money in politics. Democrats will have to work on those items while — it seems likely — pursuing the impeachment of Trump.

There are a lot of factors affecting this dynamic: Trump remains in office, and he's still making new messes that need mopping up. And any Democratic initiatives will need buy-in from both Trump and the Republican-held Senate to come to fruition. It'll be easier to do oversight and impeachment than to get bills passed.

Democrats have to try to pass legislation anyway — if only so they can go to voters in 2020 with a good-faith promise they can get more done with a Democratic president as partner. Otherwise, Americans will only turn to them, again, when they need somebody to clean up after the Republicans.