Given a rational bivariate power series $F(x,y)=\sum{a_{n,m}x^ny^m}$, the diagonal function $G(t):=\sum{a_{n,n}t^n}$ is known to be algebraic, although not rational in general. I was wondering if there were some known conditions for it to be rational. The setting I'm working with has $a_{n,m}$ non-negative integers; I'm interested in both characteristic 0 and positive characteristic.

Assume for convenience that each $a_{n,m}\in\mathbb{C}$. Consider the
proof in *Enumerative Combinatorics*, vol. 2, Theorem 6.3.3, that
$G(t)$ is algebraic. One computes the constant term (with respect to
$s$) of $F(s,t/s)$ (being careful of the meaning of $F(s,t/s)$). The
zeros of the denominator of $F(s,t/s)$ (with respect to $s$) are
algebraic functions of $t$ that enter into the formula for the
diagonal. Factor the denominator of $F(x,y)$ as $D_1(x,y)\cdots
D_k(x,y)$, where each $D_i(x,y)$ is irreducible (over
$\mathbb{C}$). Let $d_i$ be the least integer for which
$s^{d_i}D_i(s,t/s)$ has no negative exponents. The zeros of
$s^{d_i}D_i(s,t/s)$ (as a polynomial in
$s$ whose coefficients are polynomials in $t$) will all be rational
functions if and only if $s^{d_i}D_i(s,t/s)$ has degree $0$ or $1$ (in
$s$). This is equivalent to the following: either (1)
every monomial of $D_i(x,y)$ has $x$-degree minus $y$-degree equal to
$0$ or $1$, or
(2) every monomial of $D_i(x,y)$ has $x$-degree minus $y$-degree equal
to $0$ or $-1$. An example is
$$ F(x,y)=\frac{1}{(1-xy-x^2y+2x^3y^2)(1+xy^2-x^3y^3-5x^3y^4)}. $$

It seems plausible to me (and perhaps not so difficult to prove) that the above sufficient condition is also "essentially necessary." This means that we need to exclude such examples as (1) $F(x,y)=H(x^k,y^k)$, where $k\geq 2$ and $H$ satisfies the condition above, (2) "degenerate" examples like $F(x,y)=1/(1-xy^4+2x^2y^3-5x^5y^7)$, whose diagonal is just $1$.