I'm looking at the proof of the optional sampling theorem given on p.2-p.3 here http://www.math.lsa.umich.edu/~conlon/math625/chapter2.pdf.

I'm a little confused by the equivalence between (2.4) and (2.5). In particular, I would think we have
\begin{align} \mathbb{E}[f(\tilde{X}_1,\cdots,\tilde{X}_n)\tilde{X}_n]&=\mathbb{E}[\mathbb{E}[f(X_{k_1},\cdots,X_{k_n})X_{k_n}|m_1=k_1,\cdots,m_n=k_n]]\\ &=\sum_{k_1\leq\cdots\leq k_n}p(m_1=k_1,\cdots,m_n=k_n)\mathbb{E}[f(X_{k_1},\cdots,X_{k_n})X_{k_n}|m_1=k_1,\cdots,m_n=k_n] \end{align} rather than the rhs of (2.5), unless the sampling variables (I believe they're also called stopping times) are uniformly distributed in the set of values satisfying the constraints. Am I misunderstanding this, or is there a missing assumption here?
EDIT Following E-A, I get \begin{align} \mathbb{E}[f(\tilde{X}_1,\cdots,\tilde{X}_n)\tilde{X}_n]&=\sum_{k_1\leq,\cdots,\leq k_n}\int_{\omega:\{m_1=k_1,\cdots,m_n=k_n\}}f(\tilde{X}_1,\cdots,\tilde{X}_n)dP\\ &=\sum_{k_1\leq,\cdots,\leq k_n}\int_{\omega:\{m_1=k_1,\cdots,m_n=k_n\}}f(X_{k_1},\cdots,X_{k_n})dP\\ &=\sum_{k_1\leq\cdots\leq k_n} \mathbb{E}[f(X_{k_1},\cdots,X_{k_n})X_{k_n}|m_1=k_1,\cdots,m_n=k_n] \end{align} but I still don't know how that's equivalent to what I did earlier.
What they did from (2.4) to (2.5) is to simply divide it up to different events. (It is essentially linearity of expectation; you are simply dividing up your domain)
What you did is also correct.