Non-geodesically-convex optimization in the Wasserstein space