Where to place trim

Bought a house with a strange box along each wall in this room. My grandfather made me a lot of this trim, but I’m unsure whether to place it against the floor, or above the box. Not 100% sure because there is some expanding foam visible through the top of the box.

Picture 1: the box Picture 2: trim in floor Picture 3: trim on box Picture 4: expanding foam visible through