"The nonidentity problem and the two envelope problem have in common an ongoing resistance to intuitive analysis. They also share certain structural features. I argue that the two problems proceed under the same error, imagining subjects to draw haphazardly from a potpourri of actual and expected values to generate results about betterness and harm rather than, as we naturally do and always should, drawing in a more discriminating way from a more orderly array. When we play by the same set of rules in calculating the values that we then compare, we, in particular, become able to discern (1) harm in just the cases in respect of which one important type of nonidentity problem has long been thought to show "no harm done" and (2) no harm done in the two envelope problem, which purports to show "harm done" when the subject refuses endlessly to switch from one envelope to another and back again."
Roberts, M. A. (2009). The Nonidentity Problem and the Two Envelope Problem: When is One Act Better for a Person than Another? (pp. 201–228). https://doi.org/10.1007/978-1-4020-5697-0_10