My proof follows roughly the same logic as the outline in the textbook, but I'm not sure if it's quite rigorous enough.

Choose $p_a, p_b \in D$. Since $D$ is a domain, $\exists$ a polygonal curve $P_1 P_2 \cup P_2 P_3 \cup \cdots P_{n-1}P_n$ connecting $p_a$ and $p_b$.

Since $D$ is open, each point line segment $P_1, \ldots P_n$ have an open disc $A_j$ centered at $A_j$ where $j = 1, 2, \ldots, n$.

Construct the polygonal curve such that for each pair of endpoints, $P_j, P_{j+1}$, their respective open discs $A_j, A_{j+1}$ have the property that $A_j \cap A_{j+1} ≠ \emptyset$ for $j=1, 2,\ldots, n-1$.

Then, since $u$ has the property that for each of those open discs, $u(A_j)$ = some constant, $c_j$.

$u(A_1) = c_1$, $u(A_2) = c_2$, and given that $A_1 \cap A_2 \neq \emptyset$, then $c_1 = c_2$.

Repeat this argument for each pair of $A_j$ and $A_{j+1}$ until we reach $A_{n-1} \cap A_n \neq \emptyset \implies u(A_{n-1}) = u(A_n)$.

To conclude the proof, $p_a \in A_1$ and $p_b \in A_n$ meaning that $u(p_a) = u(p_b)$, and since $p_a, p_b$ were chosen arbitrarily, $u$ is constant on $D.$.

Any feedback / criticisms are much appreciated