A blessing in disguise.

A blessing in disguise.
A blessing in disguise" refers to a good outcome that initially seemed unfortunate. This expression is often used retrospectively to describe situations in which something that appeared to be a misfortune turned out to be beneficial, revealing an unexpected positive aspect.
The layoff was a blessing in disguise; it led to better job opportunities.
The layoff turned out to be a good thing as it led to better job opportunities.
Losing that contract was a blessing in disguise because it freed up our resources.
Losing that contract was beneficial because it freed up resources.
Though initially upset, she later saw her injury as a blessing in disguise as it changed her career path for the better.
She saw her injury as a positive change that altered her career path for the better.