Group action in Polynomial invariant

The following is just a basic definition in Invariant Theory, which I copied from wikipedia

"Let $$G$$ be a group, and $$V}$$ a finite-dimensional vector space over a field $$k}$$ (which in classical invariant theory was usually assumed to be the complex numbers). A representation of $$G}$$ in $$V}$$ is a group homomorphism $$\pi :G\to GL(V)}$$, which induces a group action of $$G}$$ on $$V}$$. If $$k[V]}$$ is the space of polynomial functions on $$V}$$, then the group action of $$G}$$ on $$V}$$ produces an action on $$k[V]}$$ by the following formula:

$$(g\cdot f)(x):=f(g^{-1}(x))\qquad \forall x\in V,g\in G,f\in k[V].}$$"

I did not quite understand the group action at the end. I mean, we need to prove $$((gh)\cdot f)(x)=g\cdot (h\cdot f)(x)\qquad \forall x\in V,g,h\in G,f\in k[V]$$

I have two ways to understand the right hand side:

1) $$g\cdot (h\cdot f)(x)=g\cdot f(h^{-1}(x))=f(g^{-1}h^{-1}x)$$

2) $$g\cdot (h\cdot f)(x)= (h\cdot f)(g^{-1}x)=f(h^{-1}g^{-1}x)$$

Of course, to make this a group action, the second way is correct. However, I want to ask how can one just look at $$g\cdot (h\cdot f)(x)$$ and tell which way is correct? In fact, I think the first way is more rational as we need to compute $$h\cdot f$$ first.

$$g \cdot (h \cdot f) (x)$$ is by definition the evaluation of $$g \cdot (h \cdot f)$$ on $$x$$ .
This function is of the form $$g \cdot m$$ for $$m = h \cdot f$$, thus by definition it evaluation on $$x$$ is $$m(g^{-1}x)$$ .
This is the evaluation of $$h \cdot f$$ on $$g^{-1} x$$ which is by definition $$f(h^{-1} (g^{-1}x)) =f (h^{-1}g^{-1}x)$$ .
If you denote $$f':=h.f$$ , then your asking what is $$g.f'$$. So lets see what it does to $$x$$, for convenience denote $$x'=g^{-1}.x$$
Now: $$g.f'(x)=f'(g^{-1}.x)=f'(x')=f(h^{-1}.x')=f(h^{-1}g^{-1}.x)$$