I think we would need to get rid of the key(2).time part of the expression, but I am not sure how to tell after effects to look at the inpoint, keep the induration, then i guess freeze at that time, and then freeze until the outpoint – the outduration
so for example of we had a 7 second precomp and it had animation inside from 0 to 1 second and animation from 6 to 7 seconds. and then we applied a time remap and the expression, and dragged the layer 1 second later and the out 1 second earlier ( giving us a 5 second duration ) the expression would apply the in animation to the first second from wherever this layer starts, and then backtime the last second of animation from 1 second before the outpoint of this precomp. so something like time, inpoint, inpoint + indur, 0, outpoint – inpoint – outdur, outdur.
I dont even think we need an if else statement other than to accept the fact that if in this case the layers duration was less than 2 seconds, it would not work, but that would be fine as that would be too short anyways, I guess for arguments sake we can add and if else statement that would just speed up the whole thing in the case where indur+outdur is greater than outpoint-inpoint.
does this logic work ?