Yes, that’s the way to do it. But what is the region of integration? It would be easier to answer if you had described the exact picture you had in mind. Why is Ii inside the integral? I presume you are dealing with steady currents.
Let’s set it up properly. Suppose the infinite wire lies along the y-axis and Ii is toward +ve y-axis. The finite wire lies on the x-axis from x1 to x2 and If is toward the +ve x-axis.
B due to Ii at a pt x on the x-axis =Bi = k*Ii/x, where I’ve written k for mu_0/2pi. Bi points in the –z dircn.
If we consider an elementary length dx at x, then the force on this is dF = If*Bi*(sin 90)dx = k*If*Ii*dx/x
Now you can integrate from x1 to x2 and tell us the magnitude and direction of the force?