“If only we'd just waited there, this never would have happened.”
You wanted to go to a certain restaurant, but the wait to get in was long. You put your name down on the waiting list, but your girlfriend wanted to see if the wait at another restaurant nearby was shorter. You went to the other restaurant, but they had an even longer wait. So you went back to the 1st restaurant, but you find out that they already passed you on the list and you have to be added to the bottom of the list again. You say this because you wish you hadn't tried to leave.
If only we'd just waited there, this never would have happened.
This is a way of expressing regret or anger at how something was done. It's used when you think a mistake was made, but now it's too late to change it.
The condition can be positive, as in the example at top, or negative like this:
If you hadn't distracted me, the accident never would have happened.
"If only..." is a poetic-sounding phrase that's used to express something you wish had happened. It brings to mind an image of someone imagining how much better life would be if this imaginary event had happened.
Because of its poetic tone, "if only" is not used when someone is really angry about how things happened. It's used in situations where you wish things had been different, but you accept that you can't change the past.
This can be used to express what actions should have been differently, like in the example at top, or what conditions should have different:
If only it hadn't rained, we could have cooked out on the grill.
You can use this phrase by itself, without telling what the result would be:
If only I'd listened to her...