Yes, definitely rip up that carpet. Get some fans going asap and keep the air moving to avoid mold build up and it will help with the mildew smell over time as well. Stagnant air in damp conditions is where mold thriiiiives. If it got into any wood studs and you need to pull drywall get a meter at like home depot to measure the water content of the wood and make sure it is in a satisfactory range before redoing any of that as well. We had bad experiences with that on our new construction house. Snow while roof was going on , crawl spaced flooded and wood was too wet still months later when they put new flooring in. Bad stuff
Really sorry this happened to you