This phrase is used as a polite way to complain to someone about the way that something happened in the past.
"I wish" is a way to talk about the things that you want but aren't possible or likely. When you use "I wish" to talk about things that have already happened, you are saying the way that you would like to change the past:
I wish Aiden had asked me before buying it.
I wish you'd called me first.
A similar way to criticize someone's actions or decisions is "Why didn't you ___?":
Why didn't you tell me sooner?