Migrant children hoping to reach the United States play at a shelter in Tapachula, Chiapas state, Mexico, on June 8. (Pedro Pardo/AFP/Getty Images)

On Thursday, Congress passed a $4.6 billion bill to fund humanitarian aid for migrant children at the nation’s southern border — spurred by public horror over a disturbing photo of a father and child dead facedown in the Rio Grande and reports that detained migrant children were being mistreated. President Trump is expected to sign the bill into law.

It wasn’t everything some Democrats wanted. Earlier this week, the House Democratic Caucus’s progressive wing pushed a bill, which the House passed, that restricted how the administration could use the funds and improved health and safety standards for detained migrants. But the Senate — backed by dozens of Senate Democrats and facing a veto threat from Trump — sent back a bipartisan agreement that slimmed down the House bill’s restrictions and gave some money for immigration enforcement to the Pentagon, Immigration and Customs Enforcement (ICE) and immigration judges.

House Speaker Nancy Pelosi (D-Calif.) faced both an approaching week-long Fourth of July break and stiff resistance from moderate House Democrats. She acceded to the bipartisan Senate measure over her progressive wing’s vociferous objections. On the final House vote, only 60 percent of House Democrats joined nearly every Republican to send the bill to the president.

Here are three takeaways from the bill’s passage.

1. The blame game is alive and well.

Both parties’ leaders probably thought failing to act, given widely publicized border conditions, would damage their parties’ reputations. Neither side wanted the blame. Parties often view the political consequences of a given stalemate differently, but lawmakers and leaders usually know a must-pass bill when they see it, and this one clearly was.

In this case, public exposure spurred action. For political science students, this was a classic case of political scientist E.E. Schattschneider’s notion of socializing the conflict: When you draw the public into a fight, “as likely as not, the audience determines the outcome of the fight.”

The public was shocked by the photo of drowned migrants (and stories that gave them names and faces); by the spectacle of a government lawyer appearing to defend the government for denying soap, toothbrushes and sleeping cots to migrant children; and firsthand reports of inhumane conditions in a border detention facility. As Rep. Tom Cole (R-Okla.) put it, failing to act “would be awful.”

Further, government agencies responsible for caring for migrant children were reportedly days from running out of money, strained by the surge of migrants, including unaccompanied minors and those separated from their families at the border. Lawmakers were ready to head home to face voters, increasing the pressure on Congress to act. All this made border aid a “must-pass” measure — giving Senate Majority Leader Mitch McConnell (Ky.) and his Republicans the upper hand over Senate Democrats and Pelosi and her divided majority.

2. Know when to fold ‘em.

Many viewed the outcome as a defeat for Pelosi. Consider how different this was from her firm stand during the government shutdown this winter. Then Pelosi held her caucus together against Trump’s demand that Congress fund a border wall before he would agree to reopen the government.

This time, Democrats targeted one another rather than the president. The co-chair of the House Progressive Caucus, Rep. Mark Pocan (D-Wis.), scathingly asked his colleagues via tweet when the bipartisan Problem Solvers Caucus (almost all of whom sided with the moderates) had become the “Child Abuse Caucus.” Pocan refused to back down from that attack when Democratic moderates confronted him.

Pelosi’s insurrection from her left must look familiar to recent former Republican House speakers John A. Boehner and Paul D. Ryan, who had to contend with restive party factions on their conference’s right wing. Without control of the Senate or the White House, the speaker can only cater to a far-side caucus if backed up by his or her party in the Senate, as both Boehner and Ryan learned. In this case, Senate Democrats undermined Pelosi’s position by siding overwhelmingly with Republicans. That rift gave McConnell a supermajority that quickly rejected the House approach in favor of the Senate’s.

There is a faint silver lining for Pelosi. Her majority was not technically “rolled,” meaning that a majority of Democrats voted for the final bill — even if more Republicans than Democrats voted aye. That meets the terms of the “Hastert Rule” — the informal expectation that party leaders will bring measures to the floor only if those measures are supported by a majority of their own party. Pelosi surely calculated that the timing — right before members went home to appear in Fourth of July parades — handed her moderate “majority makers” in purple districts an important chance to claim credit for responding to the humanitarian crisis at the border and to avoid blame for inaction.

3. Lawmakers can divide the dollar, but not much else.

Swift action by Congress this week might be the exception that proves the rule. Other than spending deals, including this one, the parties lately have had limited success bargaining on policy problems. Democrats blame the Senate majority leader, in particular, who relishes the criticism. The parties are too polarized to take much action on substantive issues, a problem exacerbated by the often divided House majority and an erratic president.

Not every spending issue has been easily resolved this year. Negotiations over raising strict spending caps for the coming fiscal year so far have made little progress. But the House and Senate Appropriations Committees have shown some bipartisanship: when they made deals that reopened the government this past winter, when they (eventually) delivered disaster aid last month for this year’s natural disasters, and when they funded the border agencies this week ⁠ — at least in the Senate.

Party leaders are the ones who get both sides to the final handshakes. This time, Pelosi and the vice president secured the deal. But leaders have generally relied on functional relationships within and between the House and Senate Appropriations Committees for the tough negotiating. So long as lawmakers remain focused on how much to spend — rather than on how to reform, say, the nation’s immigration and asylum laws — the legislative process can still work.

Don’t miss anything! Sign up to get TMC’s smart analysis in your inbox, three days a week.