Examination of the efficiency and losses in heat exchange devices is pivotal. Therefore, the entropy generation (EYG) and Bejan number (Be) of mixed convective heat transfer of nanofluid flow in a rectangular cavity (RCY) are evaluated in this study. Five baffles are placed at the lower hot wall of the RCY. The cold upper wall moves and causes forced convection flow of nanofluid. The magnetic field (MFD) at different angles affects the nanofluid when the Hartmann number (Ha) changes from 10 to 40. The length of stepped baffles is changed, and the values of frictional EYG, thermal EYG, and total EYG are estimated. The simulations are done using the LBM and an in-house code. The results demonstrate that the improvement in Ha decreases the amount of frictional EYG, thermal EYG, total EYG, and Be. The total EYG and Be also increase as the MFD angle is increased. The increment in the Richardson number (Ri) reduces the frictional EYG and total EYG (61.8 %) and increases the value of thermal EYG. Enhancing the length of the baffles intensifies the amount of Be and total EYG (3.4 %) and thermal EYG, but decreases the frictional EYG.