Optimality of Approximate Message Passing Algorithms for Spiked Matrix Models with Rotationally Invariant Noise