It's different if the opinion were based on Constitutional grounds. Congress can rewrite laws they've passed as they see fit, potentially rendering Supreme Court rulings based on them moot in the process. They don't have the luxury of rewriting the Constitution though, so Court rulings based on Constitutional law have significantly more lasting power. Once the precedence of that opinion is set, the freedom of Congress to do what they want in that area becomes heavily constrained. They can still pass laws that contradict that opinion, but will likely end up with a fast track in front of the Supreme Court having to convince the Court on why their law shouldn't be stricken down as unconstitutional based on that prior precedence.
[1] Title VII of the Civil Rights Act of 1964
Curious, historically what typically has stronger lasting power — a Supreme Court ruling or a law enacted by Congress? I feel like it would be the Supreme Court because the personnel churns more slowly, but there’s probably data on this.