The 23-year-old’s goal soon after his introduction as a substitute capped a 4-0 win, in a game that West Ham dominated from the moment Pablo Fornals opened the scoring inside two minutes.
Andriy Yarmolenko doubled the lead on the half-hour mark before an own goal from Andy Butler all-but ended the game as a contest after the break.
The win sets up a last-16 meeting with one of Manchester United or Liverpool for the Hammers, who have now won their last five matches.
Moyes made eight changes from the victory against West Brom with midweek matchwinner Michail Antonio and the only forward at the club one of several to drop to the bench.
Winger Yarmolenko led the line in his absence and it was good work by the Ukrainian after he drifted to the right which contributed towards a second-minute opener.
The makeshift forward produced a fine through ball to Ryan Fredericks with the outside of his boot and the defender had time to pick out the onrushing Fornals, who fired into the bottom corner for his third goal of the season.
In the previous round at Stockport, the Hammers had to contend with a mudbath, but on the London Stadium’s slick surface they were passing the ball around with purpose and regulary cutting through their opponents.
Said Benrahma had been a constant thorn in the Doncaster defence and minutes after a long-range effort had been saved, the former Brentford man created the second.
Rovers gave away possession to the Algerian and he spotted the run of Yarmolenko into the area and West Ham’s number seven found the net with a neat chip over Ellery Balcombe in the 32nd minute.
The third arrived for the Premier League outfit with 53 minutes played when captain Mark Noble drilled a corner into the front post where it got a touch and that was enough to put off Rovers defender Butler, who saw the ball bounce off his knee and find the net.
Moore’s men almost pulled a goal back when Jon Taylor’s cross came for Matt Smith at the back post, but his half-volley clipped the crossbar and went over.
Normal service was quickly resumed and Moyes handed a debut to Afolayan late on and saw the forward grab the club’s fourth with 12 minutes left in the capital.
Additional reporting by PA.