Held to a total of two runs in the first two games of the series, Chicago broke out for seven runs in the second inning.
The Cubs loaded the bases and Jared Eickhoff (0-1) then hit Rivas with a pitch. Rafael Ortega doubled to score two and Patrick Wisdom singled home two more and brought up Happ.
Happ sent a first-pitch fastball to the shrubbery atop the center field wall. The Pittsburgh native continued his torrid June and is now hitting .380 with eight RBI and three home runs this month. He said being decisive and aggressive has helped fuel his strong month.
"Just trying to see something up in the zone," Happ said. "I got a good pitch to hit there and was able to capitalize. ... You need some of those little confidence boosts and then try to ride that out."
Wisdom homered to nearly the same spot in the ballpark in the fourth.
Eickhoff made his 2022 debut and allowed 10 runs on 10 hits in 4 1/3 innings. He became the first Pirates pitcher to give up 10 runs in his first outing with the team. He also gave up 10 runs in his first start with the New York Mets in 2021.
Chicago starter Keegan Thompson (7-2) worked six innings and allowed four hits. He struck out seven and gave up one run, a solo homer by Diego Castillo in the second.
With the game out of hand late, Castillo moved from second base to the mound to pitch the ninth inning for Pittsburgh. He loaded the bases with two walks and a hit batter before Rivas hit a 65-mph offering to the right field seats for his first career grand slam.
Later in the inning, Chicago manager David Ross let relief pitcher David Robertson go to the plate instead of using his designated hitter. The infielder struck out the pitcher to end the inning.
The light moment was appreciated by the 25-43 Cubs, who have been on the other side of a few lopsided scores this season.
"His teammates were definitely enjoying that," Ross said. "It was fun. It's the first time I've laughed in the dugout in a while."
After seemingly giving up on the game by pitching Castillo, the Pirates didn't go away quietly in the ninth. Oneil Cruz drove in Castillo with a grounder and now has an RBI in all five games to start his career, including three games this season.
"It was the Diego Castillo Show," Pirates manger Derek Shelton said. "You're trying to save arms playing at 12:30 tomorrow, you end throwing a position player - and sometimes position players throw it and it becomes a game within itself."
Fellow rookie Bligh Madris hit a three-run double later in the inning after two Chicago errors.
Pirates: Designated RHP Heath Hembree for assignment to make room for Eickhoff.
Cubs: LHP Drew Smyly (oblique) threw a 30-pitch bullpen session on Tuesday.
Pirates: OF Jake Marisnick (left thumb surgery) was moved from the COVID-19 IL to the 60-day IL. He starts a rehab assignment next week, but can't be activated until July 12. ... OF Ben Gamel (left hamstring strain) will go on a rehab assignment this week. ... OF Greg Allen (left hamstring strain) will be out until at least the All-Star break.
Cubs LHP Justin Steele (2-5, 4.27 ERA) will face Pirates LHP José Quintana (1-4, 3.66) in the conclusion of the four-game series Thursday afternoon.
Ortega, Wisdom and Happ combine for a 7-run inning for the Cubs
Rafael Ortega, Patrick Wisdom and Ian Happ tally on seven runs for the Cubs in the second inning against the Pirates.