The requirement is that the passport needs to be valid until 6 months after the date of departure (or, for passports from countries in the 6-month club, the passport needs to be valid until the date of departure). The actual effect of this requirement is that:
- If your passport is not from a country in the 6-month club, your passport must be valid for at least 6 months on the date of entry, and the admit-until date on your I-94 will be no later than 6 months before your passport expires.
- If your passport is from a country in the 6-month club, your passport must be valid on the date of entry, and the admit-until date on your I-94 will be no later than your passport's expiration date.
So if you re-enter the US on your current passport (and since India is part of the 6-month club), you will be admitted until your passport expiration date in Sept 2023. If you re-enter the US on a new renewed passport, you will be admitted until the expiration date of your H1b petition.
The order between getting a new visa and renewing the passport doesn't technically matter -- even if you get the visa on the old passport, once you get the new renewed passport, you can use the visa in the old passport in combination with the new passport, as long as they are the same type of passport form the same country.
For that matter, you don't actually need to get a new visa if you will re-enter before Oct 2023 -- the visa's expiration date has no relevance to how long you are admitted. You will be admitted until the expiration date of your H1b petition.