One of the SCOTUS cases when PA got its Congressional seats un-gerrymandered
was when MD was accused of doing just what you mentioned and they allowed it to stand as a "state issue" -
U.S. Supreme Court rules in Maryland case that courts have no role in deciding partisan gerrymandering
By Luke Broadwater
The Baltimore Sun | Jun 27, 2019 at 5:30 PM
In a 5-4 decision, the U.S. Supreme Court ruled Thursday that federal courts are not the appropriate venue to resolve allegations of partisan gerrymandering a decision advocates for fair elections warned could bolster partisan manipulating of voting districts.
The conservative justices on the high court remanded cases from Maryland and North Carolina to the lower courts and instructed those courts to dismiss the complaints of partisan gerrymandering.
Excessive partisanship in districting leads to results that reasonably seem unjust, Chief Justice John Roberts wrote . But the fact that such gerrymandering is incompatible with democratic principles ... does not mean that the solution lies with the federal judiciary. We conclude that partisan gerrymandering claims present political questions beyond the reach of the federal courts.
The Maryland case concerned complaints Republicans were disadvantaged through partisan gerrymandering; while the North Carolina case made a similar allegation on behalf of Democrats.
https://www.baltimoresun.com/politics/bs-md-supreme-court-maryland-redistricting-20190620-story.html