This happens when the high limit of the rear derailleur isnt set right. The limit screws are what control how far in/out the derailleur will shift on the bike. If it is not adjusted right you can shift your rear derailleur right into the wheel.
Ive seen it happen and its not pretty. At the least you are looking at a new rear derailleur or at least lower cage of the derailleur, New chain, new derailleur hanger, and again hopefully the wheel can be saved.
Whoever set up the rear derailleur did not do it properly. Good luck with the warranty.