The problem itself is wrong. f o g is not an invertible function!
But what you need to do is to solve your equation for x, which means x must be on only one side, unlike your last line. What you'll find is a quadratic equation in x with y as a parameter (that is, treated as a constant). This will have two solutions, which is my concern.
What Pedja said amounts to saying that you can find the answer without getting a general formula for the inverse, In your work, this would mean letting y=2 before solving for x. This happens to give a single number, so you would not notice that the inverse is not a function.