That’s more complex than I anticipated. I still can’t figure out what drives the timing of the rectangle’s animation, but assuming you know, I think you can just adjust the size expression for the rectangle like this:
var s = thisComp.layer("Justin RenegadeofFunk Lundy");
var start = s.inPoint;
var end = s.outPoint;
var mid = (end-start)/2;
var w = s.sourceRectAtTime(mid).width;
var h = s.sourceRectAtTime(mid).height;
var endVal = [w,h];
var startVal = [0,h];
var startAnim = ??
var endAnim = ??
linear(time,startAnim,endAnim,startVal,endVal)
and the position expression for the rectangle like this:
var s = thisComp.layer("Justin RenegadeofFunk Lundy");
var start = s.inPoint;
var end = s.outPoint;
var mid = (end-start)/2;
var w = s.sourceRectAtTime(mid).width/2;
var h = s.sourceRectAtTime(mid).height/2;
var l = s.sourceRectAtTime(mid).left;
var t = s.sourceRectAtTime(mid).top;
endVal = [w+l,h+t];
startVal = endVal - [w,0];
var startAnim = ??
var endAnim = ??
linear(time,startAnim,endAnim,startVal,endVal)
although (based on the video you posted) you may want a custom easing rather than linear(), which may add another level of complexity.