The Tesla app lets you set buy/sell rates for each TOU period. So the optimal behavior with just two tiers depends on 4 numbers.
For example, say off peak you can buy a kWh for $0.20 and you get to sell one for $0.15, and on peak you can buy a kWh for $0.40 and sell one for $0.35. [Made up numbers.] You generate 1.1 kWh off-peak. You can (a) use it to offset $0.22 of energy you'd otherwise buy while it's being generated (b) sell it for $0.165 immediately (c) put it in a battery to displace a kWh you'd have to buy later during Peak for $0.40, or (d) put it in a battery to sell it later for $0.35.
With the above numbers, economically c > d > a > b. So you want the system to fill the battery from off-peak solar, if it can, and to use excess instantaneous solar to the extent possible. Then you want it to cover all your house loads during peak, and export everything else (while never drawing from the grid).
I think on residential the billing interval is 1 hour, and I think that the NBCs (the reason for a NEM2 difference in buy vs sell) are also only charged on that 1 hour net usage. So the above reckoning really only applies hour by hour, rather than instantaneously.
Cheers, Wayne