SAN JUAN, P.R. — It had been planned for months: the largest-ever congressional delegation to Puerto Rico. It would start with briefings on the continuing effects of Hurricane Maria, end with a charity performance of “Hamilton” and include a little down time on the beach.

And then the government shut down.

As they returned to Washington for Monday night votes, the 39 members of Congress who traveled to Puerto Rico over the weekend were taking fire from Fox News, President Trump’s communications team and the president himself.

The White House seized on the idea of Democrats “partying on the beach instead of negotiating,” as polls have found most voters blaming Trump for the 24-day impasse over funding the federal government, the longest shutdown in history.

“I’ve been here all weekend,” the president told reporters outside the White House. “A lot of the Democrats were in Puerto Rico celebrating something. I don’t know, maybe they’re celebrating the shutdown.”

The main trip was organized by Bold PAC, the electoral arm of the Congressional Hispanic Caucus, which flew members south for two days of meetings and receptions. It was set to coincide with a two-week San Juan run of “Hamilton,” the proceeds of which are earmarked for a Puerto Rican arts fund; members of Congress paid $500 for their own tickets. While organizers were wary of the optics, there was no talk of canceling the trip.

“We were not going to let Donald Trump stop us, whether he created a shutdown or whether he wrote mean tweets about us,” said Rep. Tony Cárdenas (D-Calif.), chairman of Bold PAC. “Millions of people are being affected all over the country, including in Puerto Rico. Projects are being stopped, right now. And the president is exacerbating this situation, from Puerto Rico to California.”

According to members who participated, the three-day event featured informational sessions on the damage from the 2017 hurricane, meetings with Gov. Ricardo Rosselló, presentations on the controversial oversight board created to meet the island’s bond obligations, and information on how residents of territories can’t access many of the government services available to residents of the 50 states.

Lawmakers flew to Puerto Rico as the White House was reportedly considering ways to divert disaster funds earmarked for hurricane relief toward the construction of a wall on the U.S.-Mexico border. The White House’s handling of the 2017 hurricane, including a much-derided event at which the president tossed paper towels to survivors, loomed over the meeting.

“What I saw was an island that still needs a lot of help,” said Rep. Mike Levin (D-Calif.), a freshman from the San Diego area, who added that he had never been to Puerto Rico before. “A lot of the preexisting challenges here were exacerbated by the hurricane.”

One goal of the weekend, said organizers, was to educate members on the questions their new House Democratic majority, with oversight power, could ask about the recovery effort; Rep. Jerrold Nadler (D-N.Y.), the new chairman of the House Judiciary Committee, was among the attendees.

But by Saturday evening, the news of a trip in sunny Puerto Rico had reverberated in conservative media. In an interview on her Fox News show, Jeanine Pirro incorrectly told the president that House Speaker Nancy Pelosi (D-Calif.) was “in Puerto Rico with a bunch of Democrats and lobbyists enjoying the sun and partying down there.” (Pelosi did not attend the summit, and Pirro apologized for her comment.)

The next day, a Fox News producer tweeted a photograph of Sen. Robert Menendez (D-N.J.), shirtless and wearing swim trunks, at an unnamed beach resort. “Democrats claim to care about federal workers forced to sell clothes to make ends meet, but I guess the only clothes they really care about are ‘resort casual,’ ” tweeted deputy White House press secretary Hogan Gidley, linking to a report on the trip.

“Nobody would get angry if 30 Congress members went to Kansas, or to Arkansas, or to Texas,” said Henry R. Muñoz, the finance chairman of the Democratic National Committee. “It’s insulting, and there’s an accent on the insult.”

On Monday, many of the members of Congress stayed in San Juan to attend the Latino Victory Fund’s annual political summit. It began with remarks from Lin-Manuel Miranda, the composer and star of “Hamilton,” who has sparred with the president on Twitter over his response to the 2017 hurricane.

“You’re here to work, despite what anyone might claim,” Miranda said. “You’re working on behalf of people who are American citizens.”

Former Housing and Urban Development secretary Julián Castro, who made the summit the first stop of his 2020 presidential campaign, used his own remarks to criticize the idea of moving money from Puerto Rico’s relief effort to the construction of a border wall.

He then headed to a “community transformation center,” where San Juan Mayor Carmen Yulín Cruz showed him how the city was distributing supplies to prepare residents in the event of another disaster. Asked about the president, both Castro and Yulín Cruz praised the members of Congress and the island’s leaders — and then unloaded.

“I wish that the president would actually spend more time doing the job of being president instead of fighting with people on Twitter, spending so much time golfing, and not going to his first meeting until 11 a.m.,” Castro said. “We have a president who’s putting in less time than the average part-time worker.”

Yulín Cruz, who was sharply critical of the White House’s response to Hurricane Maria, said that the president didn’t have “the moral authority” to talk about Puerto Rico.

“He came here for four hours and threw paper towels at us,” Yulín Cruz said. “Bring a clown to the White House, and you’re going to get a circus.”

John Wagner contributed reporting from Washington.