Update:
I found the following expressions which works fine for the text box to adapt to first line of text.
margin = 30;
t1=thisComp.layer(“textLayer”);
s1=t1.sourceRectAtTime();
t2=thisComp.layer(“textLayer 2”);
s2=t2.sourceRectAtTime();
l = t1.toComp([s1.left, s1.top])[0] – margin;
r = t2.toComp([s2.left+s2.width, s1.top])[0] + margin;
t = Math.min(t1.toComp([s1.left, s1.top])[1], t2.toComp([s2.left+s2.width, s2.top])[1]) – margin;
b = Math.max(t1.toComp([s1.left, s1.top+s1.height])[1], t2.toComp([s2.left+s2.width, s2.top+s2.height])[1]) + margin;
createPath( [fromComp([l,t]), fromComp([r,t]), fromComp([r,b]), fromComp([l,b])], [],[], true);
So if I am assuming correctly I would have to replace the expression for r with an expression that looks at the width of both text layers? Would anyone know how to do that? THX