If you use shape layers as track mattes instead of masks, you can easily calculate the width of the layer by adding the left value to sourceRectAtTime().width. Without understanding how you are changing the size of the Mask. Personally I would drive the entire animation with expressions. There would be no keyframes. I would use time minus in-point and time minus out point minus the animation duration and a linear or ease interpolation to setup the animation. Combine that with sourceRectAtTime to calculate the size of the text layer plus any necessary padding and some simple math for position and you have the whole thing. If you added some sliders you could change the timing of the in and out animation, and the animation would always start and end at the end of a frame. Combine a starting and ending protected area in the timeline and you have an animated lower third animation that can have any duration you like and that animated in and out perfectly.
I'll demonstrate how to move a text layer in from the left so that the first letter is positioned to the right of the left edge of the composition by a specific percentage of the comp width, then slides out to the right until. Applying this expression to any text layer will get it to animate based on the layer's in and out points. The comments in the expression preceeded by double backslashes show you what values to change to position the text layer where you want it to be and control the timing of the animation. I hope this helps:
siz = sourceRectAtTime();
w = siz.width - siz.left;
h = siz.height - siz.top;
rest = thisComp.width * .08;//percentage of the comp width for resting position
hP = thisComp.height * .9;//percentage of the comp height for the text
mIn = 20;//Number of frames it takes to move the text in
mOut = 40;//Number of frames it takes to move outPoint
p1 = w - siz.width * 2;
p2 = p1 + siz.width + rest;
p3 = thisComp.width - siz.width + w;
t = (time - inPoint) / thisComp.frameDuration;
endT = (outPoint) / thisComp.frameDuration;
if (t < mIn + 1){
x = easeIn(t, 0, mIn, p1, p2);
}
else{
x = easeOut(t, endT - mOut, endT, p2, p3)
}
y = h - siz.height + hP - siz.height;
[x, y]
No matter what the paragraph justification or the baseline shift this expression will move a text layer from offscreen on the right side of a comp to 8% of the comp width in 20 frames, then move it offscreen to the left over the last 40 frames of the layer while the bottom of the text layer stays at 75% of the comp height. You could replace the percentages (.08 and .90) and the number of frames (20 and 40) with expression control sliders to have a fully customizable MOGRT thata would let you customize the position and the speed of the animation.
Tie the second text layer, and if needed, the Background Graphic to the position of the main text layer and you should have it.
The expression could be simpler if you did not compensate for paragraph justification or baseilne shift. I ahve about 40 animation presets for Text layers that I have written that do all kinds of moves with and without backgrounds.
One day soon I will publish a tutorial series that should help anyone interested in automating animatiion to create their own presets to speed up their work and differentiate it from stock motiion graphics templates that so many are using.