For what its worth, the rear derailleur could have been fine when the bike was shipped, but could have also been bumped during shipping, or even pulling it out of the box.
Be happy you had the dork disk on and you weren't going so fast that the derailleur swung around and nailed the seat stay, cracking it in half. Been there, done that.
On the upside, learning the hardway means you never make the same mistake again.
__________________
Hey guys, lets go play bikes!
Strava