About 40,000 ready for war passed over before YHWH for battle, to the plains of Jericho.
Joshua 4:13

These men weren't the whole force from the eastern tribes. They were men from all the tribes, serving as an armed escort while the rest of the people crossed the Jordan and set up camp.

"Before YHWH" doesn't mean ahead of him in time or space, but more like "under his oversight" like a commander reviewing the troops as they pass by.