This problem is interesting because an intuitive approach leads to a quick solution.
Consider a simplified version. Randomly draw every ball from the urn, one at a time, and lay them down in sequence as you do so. The sequence ends with a string of all green or all red balls. You will eventually get to keep this "monochromatic suffix" as a reward, but for now let's suppose you care only about keeping the red balls. What is your expected reward?
Look at the sequence you laid down. It consists of $m$ red balls among which $n$ green balls are interspersed. These green balls divide the red balls into $n+1$ groups (of which many may be empty). Intuitively, we would figure each group -- including the last -- must therefore contain $m/(n+1)$ red balls on average.
This can be demonstrated with a basic combinatorial argument, but that isn't necessary. Computer science teaches us it can be much easier to check the solution to a problem than to produce it in the first place. Therefore, let's immediately check this guess to see whether it needs any correcting.
The check is done by mathematical induction on the number of balls in the urn, $N=m+n.$ The formula is correct when the urn is empty; that is, when $N=m+n=0$ it gives the right answer $0/(0+1)=0.$ Suppose now the formula happens to be true for $N \ge0.$ The formula clearly is correct when $m=0$ or $n=0,$ because in either case you will keep all the red balls in the urn and the formula counts them. So, suppose both $m$ and $n$ are nonzero. We only need to show the formula holds for all the other possible values with $m+n=N;$ that is, $m=1,2,\ldots,N-1$ and $n=N-m.$
The expected reward $f(m,n),$ by definition, is the expected reward after drawing a red ball times the chance of drawing a red ball, plus the expected reward after drawing a green ball times the chance of drawing a green ball:
$$f(m,n) = f(m-1,n)\left(\frac{m}{m+n}\right) + f(m,n-1)\left(\frac{n}{m+n}\right) .$$
Since both $(m-1)+n$ and $m+(n-1)$ are less than $N,$ and we have assumed the formula holds in such cases, we may plug it into the forgoing equation to produce
$$f(m,n) =\frac{m-1}{n+1} \left(\frac{m}{m+n}\right) + \frac{m}{(n-1)+1}\left(\frac{n}{m+n}\right) = \frac{m}{n+1},$$
QED.
The analysis for the green balls is identical: just swap the colors, which swaps $m$ and $n.$ Thus, the total reward for both red and green balls is
$$f(m,n) + f(n,m) = \frac{m}{n+1} + \frac{n}{m+1}.$$